*chuckle*") * feed_category_list() * filter_xss($val) * format_table_name($table, $pluralize = false, $stripunderscores = true, $strtoupper = false, $strtolower = true, $ucwords = true) * gen_random_string($length=5) * get_alerts($scope = "",$partnerid = "",$donorid = "",$userid = "",$alertid = "",$allseen = false) * get_comments($key) * get_donor_array($donorid, $sessionid = "", $use_temp_data = false) * get_generations($table, $showgens = array('1','2','3','4'), $offset = 0, $scope = "dsf", $hidden = 0, $consolidated = true, $return = "display") * get_google_key() * get_link_ref($link_ref) * get_news($id, $dept, $format = "full") * get_partner_array($partnerid, $projectid = "", $locationid = "", $db = "cristina") * get_partner_search_query($preset = '', $status = 'active', $state = '', $date_begin = '', $date_end = '') * getGeo($donorid,$partnerid,$sessionid,$locationid,$database,$table,$update) * getmicrotime() * getNth($n) * getSize($bytes, $id) * is_profile_complete($partnerid, $projectid) * kattare_decode($text, $pass = "Cr1sT1n@") * kattare_encode($text, $pass = "Cr1sT1n@") * list_news($how_many = 5, $section = "all", $format = "list", $category = "", $subcategory = "", $tags = "") * log_this_page($scope = "") * matching_template($donorid, $sessionid, $partnerid) * mime_content_type ($f) * my_get_headers($url) * ncf_ldap_modify($full_name,$info) * ncf_mail($to = "NCF Webmaster
\n"; $body_html .= "
FIELD | \n"; $body_html .= "OLD VALUE | \n"; $body_html .= "NEW VALUE | \n"; $body_html .= "
{$key} | \n"; $body_html .= "{$old_value_html} | \n"; $body_html .= "{$new_value_html} | \n"; $body_html .= "
\n"; $body_html .= "Changes were made by {$user->data['username']} on " . date("F j, Y, g:i a") . "
\n"; $body_text .= "Changes were made by {$user->data['username']} on " . date("F j, Y, g:i a") . "\n\n"; // Wrap html text with proper html/css... $body_html = "\n
\n\n\n\n" . $body_html . "\n\n"; // Who to send to... $to = "partner_updates@cristina.org"; $to_name = "NCF Staff"; // Send the email report... if ($send_report) { ncf_mail($to = "{$to_name} <{$to}>", $from = "NCF Webmaster" . print_r($eligible,true) . "\n"; // $conditions['has_passing_location'] = true; // Check to make sure the partner has active status... $status_result = my_db_query("SELECT `id` FROM `partner_info` WHERE (`status` like 'active%') AND (`id` = {$partnerid})"); // Check to make sure the project has proper status... $project_status_result = my_db_query("SELECT `id` FROM `partner_project` WHERE (`project_status` like 'active' or `project_status` like 'current')"); // Assign condition fixit buttons... $fixit = array("has_mission_statement" => '', "aop_terms_conditions" => '', "has_needs" => '', "placement_contact_specified" => '', "has_geo-located_address" => '', "has_verified_phone" => '', "set_publishing_options" => ''); // Override aop_terms fixit button with update button where applicable... if ($eligible[$projectid]['aop_terms_conditions']) { $aop_terms_result = my_db_query("SELECT * FROM `aop_terms` WHERE (`partnerid` = '" . mysql_escape_string($partnerid) . "') ORDER BY `id` DESC LIMIT 1"); if (mysql_numrows($aop_terms_result)) { $aop_existing = mysql_fetch_assoc($aop_terms_result); // Reasons to display update button include: // 1) The terms in storage is a file upload // 2) The terms in storage was signed by a different user // 3) The terms in storage was signed before the timestamp of the agreement file if ($aop_existing['uploadid'] || ($aop_existing['phpbb_user_id'] != $userdata['user_id']) || (strtotime($aop_existing['date_signed']) < filemtime("includes/aop_terms.inc"))) { $fixit['aop_terms_conditions'] = ''; $update_aop = true; //$output .= "\n"; } } } //$output .= "(Click for more help...)
\n"; //$output .= "Want to see how your donors are going to find you?
\n"; $output_email .= "
\n"; $output_email_text .= "Overall Eligibility: {$eligible[$projectid]['overall_eligibility']}\n\n"; if ($latlon) { $locator_link = ""; $locator_endlink = ""; } if (mysql_numrows($status_result) && mysql_numrows($project_status_result)) { if ($num_passed && $num_failed && ($eligible[$projectid]['overall_eligibility'] == "PASS")) { $analysis .= "Congratulations, at least one of your project locations is currently listed in the Non-Profit Locator! At this time, "; if ($num_failed > 1) { $analysis .= "{$num_failed} locations are"; } else { $analysis .= "{$num_failed} location is"; } $analysis .= " not eligible due to problems outlined below.\n"; } else if ($num_passed && !$num_failed && ($eligible[$projectid]['overall_eligibility'] == "PASS")) { $analysis .= "Congratulations, all project locations are currently listed in the {$locator_link}Non-Profit Locator!{$locator_endlink}\n"; if ($num_passed > 1) { $analysis .= " Click the buttons next to each of your locations below to see your project as donors will see it."; } } else if ((!$num_passed && $num_failed) || ($eligible[$projectid]['overall_eligibility'] != "PASS")) { $analysis .= "There are items below that must be corrected before your project can be published in the Non-Profit locator.\n"; } else { $analysis .= "Fail: {$num_failed}, Pass: {$num_passed}"; } } else { if (!mysql_numrows($status_result)) { $analysis .= "Your organization's Cristina Network account is not currently active and so cannot appear in the Non-Profit Locator. If you feel this is in error, please contact webmaster@cristina.org."; } else { $analysis .= "Your project is not currently active and so cannot appear in the Non-Profit Locator. To change this, adjust the Operational Status option in the Project Details section."; } } /* if ($eligible[$projectid]['overall_eligibility'] == "PASS") { if ($num_passed) { $output .= "
\ncreate_phpbb3_user() called with the following params:\n{$username}, {$user_email}, {$user_password}, {$send_welcome}, " . print_r($user_array, true) . "
\n"; // // some of the phpbb3 stuff requires globals $phpbb_root_path, $phpEx // $GLOBAL['phpbb_root_path'] = "/www/proto/phpbb3/"; $GLOBAL['phpEx'] = "php"; //echo "
\nTrying to include utf_tools.php and functions_user_ncf.php
\n"; //require_once($GLOBAL['phpbb_root_path'] . 'common.php'); //require_once($GLOBAL['phpbb_root_path'] . 'includes/ucp/ucp_register.php'); //require_once($GLOBAL['phpbb_root_path'] . "includes/db/dbal." . $GLOBAL['phpEx']); require_once($GLOBAL['phpbb_root_path'] . "includes/utf/utf_tools." . $GLOBAL['phpEx']); require_once($GLOBAL['phpbb_root_path'] . "includes/functions_user_ncf." . $GLOBAL['phpEx']); //echo "
\nincludes called...
\n"; $user_array['username'] = $username; $user_array['user_email'] = $user_email; if ($user_array['user_type'] == "") $user_array['user_type'] = 0; if ($user_array['group_id'] == "") $user_array['group_id'] = 71; $user_array['user_password'] = phpbb_hash($user_password); // // these can be passed in via the array arg... // // $user_array['user_occ'] = $user_occ; // $user_array['user_website'] = $user_website; // $user_array['user_from'] = $user_from; // // little trick to get the db pointer flipped over to the phpbb3 database // so that we can use the phpbb_hash and user_add functions. // my_db_query("use phpbb3", "phpbb3"); // // phpbb3 function to add a user... // //echo "calling user_add() with array:\n" . print_r($user_array,true); $phpbb_user_id = user_add($user_array); group_user_add(9, array($phpbb_user_id)); // Set the aes_password in the ncf_fields table... if ($user_password != "") { include_once('Crypt/AES.php'); $aes = new Crypt_AES(); $aes->setKey('NCF AES Password Key'); $aes_password = base64_encode($aes->encrypt($user_password)); $sql = "INSERT INTO ncf_fields (user_id, aes_password) VALUES ($phpbb_user_id, '$aes_password') ON DUPLICATE KEY UPDATE aes_password = '$aes_password'"; $db->sql_query($sql); } $update_text = "ACCOUNT CREATED"; if ($send_welcome) { if ($welcome_message == "") { $welcome_message = "Greetings, Please click the link below to gain access to the Cristina Network website. Be sure to use the following details when entering your Cristina Passport or you will not be able to access the website and collaborate with your colleagues. [PASSPORT_DETAILS] We look forward to seeing you online!"; } $cc = "brian@cristina.org"; if ($username && $user_email) { $to = "{$username} <{$user_email}>"; } else { $to = $user_email; } $from = "{$user->data['username']} <{$user->data['user_email']}>"; $passport_details = "Cristina Network URL: https://www.cristinanetwork.org/\n"; $passport_details .= " Email: " . $user_email . "\n"; //$passport_details .= "Username: " . $username . "\n"; $passport_details .= "Password: " . $user_password . "\n"; $body_text = preg_replace("/\[PASSPORT_DETAILS\]/i", $passport_details, $welcome_message); ncf_mail($to, $from, 'Your NEW Cristina Network Account...', $body_text, '', $cc, $bcc, $priority, ''); $update_text .= " - EMAIL SENT"; } my_db_query("use cristina", "cristina"); // Link this passport to this partnerid... if ($partnerid) { my_db_query("INSERT INTO `partner_passport_link` (`phpbb_user_id`,`partnerid`) VALUES ('{$phpbb_user_id}','{$partnerid}')"); } return $phpbb_user_id; } } // Slightly more refined microtime method... if (!function_exists('getmicrotime')) { function getmicrotime() { $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; return ($mtime); } } // Returns a properly formatted table name (Pda becomes PDA, etc)... if (!function_exists('format_table_name')) { function format_table_name($table, $pluralize = false, $stripunderscores = true, $strtoupper = false, $strtolower = true, $ucwords = true) { if ($stripunderscores) { $table = str_replace("_"," ",$table); } if ($strtoupper) { $table = strtoupper($table); } if ($strtolower) { $table = strtolower($table); } if ($pluralize) { $table .= "s"; $table = str_replace("mouses","mice",$table); $table = str_replace("softwares","software items",$table); } if ($ucwords) { $table = ucwords($table); $table = str_replace("Pc","PC",$table); $table = str_replace("Ram","RAM",$table); $table = str_replace("Cdrom","CDROM",$table); $table = str_replace("Pda","PDA",$table); $table = str_replace("Lan","LAN",$table); $table = str_replace("Nic","NIC",$table); $table = str_replace("Cpu","CPU",$table); $table = preg_replace("/CPU \(p/i","CPU (P",$table); $table = str_replace("Pen/d","Pen/D",$table); $table = str_replace("Allinone","All-In-One",$table); $table = str_replace("All-in-one","All-In-One",$table); $table = str_replace("Network Devices","Routers & Switches",$table); $table = str_replace("Network Device","Router & Switch",$table); $table = str_replace("Os","OS",$table); } return ($table); } } // Get CGPN alerts... if (!function_exists('get_alerts')) { function get_alerts($scope = "",$partnerid = "",$donorid = "",$userid = "",$alertid = "",$allseen = false) { global $userdata; global $user; //global $_SERVER['PHP_SELF']; //global $_SERVER; global $key; $userdata = $user->data; if ($scope) { $search .= "and (scope = '{$scope}') "; } if ($partnerid) { $search .= "and (partnerid = {$partnerid}) "; } if ($donorid) { $search .= "and (donorid = {$donorid}) "; } if ($userid) { $search .= "and (userid = {$userid}) "; } if ($alertid) { $search .= "and (id = {$alertid}) "; } // Get all alerts that pertain to this user... if (!$search) { // Generate partnerid query... $partnerid_result = my_db_query("SELECT * FROM `partner_passport_link` WHERE `phpbb_user_id` = {$user->data['user_id']}"); if (mysql_numrows($partnerid_result)) { $i = 0; while ($entry = mysql_fetch_assoc($partnerid_result)) { if ($where_partnerid && ($i < mysql_numrows($partnerid_result))) { $where_partnerid .= " || "; } $where_partnerid .= "partnerid = {$entry['partnerid']}"; $i++; } if ($where_partnerid) { $where_partnerid = "|| ({$where_partnerid})"; } } // Generate donorid query... if ($userdata['donorids'][0]) { $i = 0; foreach ($userdata['donorids'] as $donorid) { if ($where_donorid && ($i < sizeof($userdata['donorids']))) { $where_donorid .= " || "; } $where_donorid .= "donorid = {$donorid}"; $i++; } if ($where_donorid) { $where_donorid = "|| ({$where_donorid})"; } } if (preg_match("/proto/",$_SERVER['SERVER_NAME'])) { //echo "
USERDATA\n"; //print_r($user->data); //echo "\n"; //echo "my_db_query(\"select * from cgpn_alerts where 1 and ((scope = '' and partnerid = '' and donorid = '' and userid = '') || (scope != '' and partnerid = '' and donorid = '' and userid = '') {$where_partnerid} {$where_donorid} || (userid = {$userdata['user_id']}))\");
\n"; } $alerts_result = my_db_query("select * from cgpn_alerts where 1 and ((scope = '' and partnerid = '' and donorid = '' and userid = '') || (scope != '' and partnerid = '' and donorid = '' and userid = '') {$where_partnerid} {$where_donorid} || (userid = {$userdata['user_id']})) order by id desc"); if (mysql_numrows($alerts_result)) { while ($alerts = mysql_fetch_assoc($alerts_result)) { // Site-wide alerts... if (!$alerts['scope'] && !$alerts['partnerid'] && !$alerts['donorid'] && !$alerts['userid']) { if (is_array($master_alerts['system_alerts'])) { array_push($master_alerts['system_alerts'], $alerts); } else { $master_alerts['system_alerts'] = array($alerts); } // Scope-specific alerts... //} else if ($alerts['scope'] && !$alerts['partnerid'] && !$alerts['donorid'] && !$alerts['userid']) { } else if ($alerts['scope']) { if ($key) { $page = $key . ".html"; } else { $page = $_SERVER['REQUEST_URI']; } //if (eregi(trim(ereg_replace("/","",$page)),$alerts['scope']) || (substr($alerts['scope'],0,2) == "*:") || ($allseen)) { if (preg_match("/" . trim(str_replace("/","",$page) . "/i"),$alerts['scope']) || (substr($alerts['scope'],0,2) == "*:") || ($allseen)) { if (is_array($master_alerts['scope_alerts'])) { array_push($master_alerts['scope_alerts'], $alerts); } else { $master_alerts['scope_alerts'] = array($alerts); } } else { //echo "var " . rand() . " = '" . trim(ereg_replace("/","",$_SERVER['SCRIPT_URL'])) . " not found in {$alerts['scope']} and allseen = {$allseen}'\n"; } // Partner-specific alerts... } else if ($alerts['partnerid'] && !$alerts['userid']) { if (is_array($master_alerts['partner_alerts'])) { array_push($master_alerts['partner_alerts'], $alerts); } else { $master_alerts['partner_alerts'] = array($alerts); } // Donor-specific alerts... } else if ($alerts['donorid'] && !$alerts['userid']) { if (is_array($master_alerts['donor_alerts'])) { array_push($master_alerts['donor_alerts'], $alerts); } else { $master_alerts['donor_alerts'] = array($alerts); } // User-specific alerts... } else if ($alerts['userid']) { if (is_array($master_alerts['user_alerts'])) { array_push($master_alerts['user_alerts'], $alerts); } else { $master_alerts['user_alerts'] = array($alerts); } } } } // Get specific alert... } else { $alerts_result = my_db_query("select * from cgpn_alerts where 1 {$search}"); if (mysql_numrows($alerts_result)) { while ($alerts = mysql_fetch_assoc($alerts_result)) { if (!$alerts['scope'] && !$alerts['partnerid'] && !$alerts['donorid'] && !$alerts['userid']) { $array_key = "system_alerts"; } if ($alerts['scope']) { $array_key = "scope_alerts"; } if ($alerts['partnerid']) { $array_key = "partner_alerts"; } if ($alerts['donorid']) { $array_key = "donor_alerts"; } if ($alerts['userid']) { $array_key = "user_alerts"; } $master_alerts[$array_key] = array($alerts); } } } // Remove any seen alerts... $seen_result = my_db_query("select * from cgpn_alerts_seen where (userid = {$userdata['user_id']})"); if (mysql_numrows($seen_result)) { while ($alerts = mysql_fetch_assoc($seen_result)) { $seen[$alerts['alertid']] = $alerts; } if (sizeof($master_alerts)) { foreach ($master_alerts as $alertkey => $alerts) { foreach ($alerts as $alert) { if (!$seen[$alert['id']] && !$seen[$alert['id']]['show_again']) { // Go ahead and display this alert... if (is_array($return_alerts[$alertkey])) { array_push($return_alerts[$alertkey],$alert); } else { $return_alerts[$alertkey] = array($alert); } // Seen it, but see if they've asked to see it again... } else { if (($seen[$alert['id']]['show_again'] == "next_login") || $allseen) { // Compare sessions... if (($seen[$alert['id']]['session'] != $userdata['session_id']) || $allseen) { // Go ahead and display this alert... if (is_array($return_alerts[$alertkey])) { array_push($return_alerts[$alertkey],$alert); } else { $return_alerts[$alertkey] = array($alert); } } } else { //echo "\n"; } $alert['last_seen'] = $seen[$alert['id']]['displayed']; } } } } } else { $return_alerts = $master_alerts; } return($return_alerts); }} // Descriptive error output... if (!function_exists('error_out')) { function error_out($reason = "General Protection Fault
*chuckle*") { global $header_output_finished; $included_files = get_included_files(); $included_header = false; foreach($included_files as $filename) { if (preg_match("/header/i", $filename)) $included_header = true; } if ($included_header && $header_output_finished) { echo "
An Error Has Occurred:
\n"; echo "
$reason
\n"; include "/www/proto/includes/footer.inc"; } else { echo "
An Error Has Occurred:
\n"; echo "
$reason
\n"; //mail("ethan@cristina.org", "Cristina DEBUG " . $_SERVER['PHP_SELF'], $reason); //mail("brian@cristina.org", "Cristina DEBUG " . $_SERVER['PHP_SELF'], $reason); } exit(); }} // Calculate number of days between two dates... if (!function_exists('diff_days')) { function diff_days($start_date, $end_date) { return floor(abs(strtotime($start_date) - strtotime($end_date))/86400); }} if (!function_exists('kattare_encode')) { function kattare_encode($text, $pass = "Cr1sT1n@") { $level = 30; $key = ""; for ($i=0; $i<$level; $i++) { $mymd[$i] = md5(substr($pass,($i%strlen($pass)),1)); } for ($a=0; $a<32; $a++) for ($i=0; $i<$level; $i++) { $key .= substr($mymd[$i],$a,1); } for ($i=0; $i
\n" . print_r($output,true) . "\n"; } // Process the blind carbon copy (Bcc)... if ($bcc) { $mail->ClearAddresses(); $mail->ClearCCs(); $mail->ClearBCCs(); ncf_mail($bcc, $from, $subject, $body_text, $body_html, "", "", $priority, $attachments); } return $output; }} if (!function_exists('embed_images')) { function embed_images(&$msg_body,$mail){ global $output; global $mail; // Get all img tags... preg_match_all('/]*src=[\'"]([^\'"]+)[\'"].*>/i', $msg_body, $matches); if (!isset($matches[0])) return; $output[] = sizeof($matches[0]) . " images found\n"; $embedded = array(); foreach ($matches[0] as $index => $img) { // make cid $id = 'img'.$index; $src_orig = $matches[1][$index]; $output[] = "Image found: {$src_orig}\n"; $src = str_replace("%20"," ",$matches[1][$index]); $local_src = str_replace("https://www.cristina.org","/www/proto",$src); if (!in_array($local_src,$embedded) && file_exists($local_src)) { $mail->AddEmbeddedImage($local_src,$id); $embedded[] = $src; $output[] = "Image embedded: {$local_src}\n"; } else { $output[] = "Image not found or already embeded: {$local_src}\n"; } // Finally, replace the src for the file in the msg_body... if (in_array($src,$embedded)) { $msg_body = str_replace($src_orig,'cid:'.$id, $msg_body); $output[] = "msg_body HTML updated with new source cid: {$id}\n"; } } return $msg_body; }} // // snags the mime type of a file on the local filesystem // if (!function_exists('mime_content_type')) { function mime_content_type ($f) { return trim(exec('file -bi ' . escapeshellarg($f))); }} // // sends mail for ncf using smtp... also handles image and file attachments // if (!function_exists('ncf_mail')) { function ncf_mail($to = "NCF Webmaster
') && !stristr($body_html, ' ","\n ",quoted_printable_encode($body_html)) . "\n\n";
$body .= "--{$boundary_2}--\n\n";
//
// attach any images detected above
//
for ($i = 0; $i \n";
$query = preg_replace("/\[$this_field\]/",$this_value,$query);
}
$m++;
}
// Swap in pledge specific variables including sessionid, partnerid...
$query = preg_replace("/\[partnerid\]/i",$partnerid,preg_replace("/\[sessionid\]/i",$sessionid,preg_replace("/\[donorid\]/i",$donorid,$query)));
//$GLOBALS['debug_output'] .= "my_db_query(\"cristina\" , \"$query\"); \n";
//echo "Executing template query: my_db_query(\"cristina\" , \"$query\");\n";
// Now see if executing the query results in a match...
$check_result = my_db_query("$query");
$check_num = mysql_numrows($check_result);
if ($check_num > 0) {
$matching_template = $template_name;
echo "Template Match: {$matching_template}\n";
return $matching_template;
$GLOBALS['debug_output'] .=" Template Match! DONORID: {$donorid} SESSIONID: {$sessionid} matches the $matching_template template.\n";
} else {
//$GLOBALS['debug_output'] .=" Application match not found for query: {$query} \n";
}
$k++;
}
$j++;
}
//echo "No matching template found... use default\n";
$default_template = "Default Schedule";
return $default_template;
}
/*
* DESCRIPTION
*
* This script includes the getGeo() function that uses the Google/Yahoo Maps API to
* ellicit lat/long data for a supplied address.
*
*
* required:
*
* donorid/partnerid ID record to lookup
* database Tells the function whether to use cristina or cristina_tmp
* table Which table should the function look for / update address info
*
* optional:
*
* update Whether to update the database with found lat/lon (TRUE/FALSE)
*
* global:
*
* precision To what level of detail did the Geo service make a match?
* Possible matches include:
* Google (0 - 9) 9 bldg, 8 address, 7 street, and so on...
* Yahoo (state,city,zip+2,zip+4,street,address) More?
* lat Found latitude (e.g. 40.023571)
* lon Found longitude (e.g. -98.07122)
*/
function getGeo($donorid,$partnerid,$sessionid,$locationid,$database,$table,$update) {
//$GLOBALS['debug'] = true;
global $find_loc;
if ($GLOBALS['debug']) { echo "\n"; }
$contact_array = false;
if (is_array($donorid)) {
// ok, so donorid is misleading, for the dsf3 we needed to take in an array that is all of the donor info
$address1 = $donorid['address1'];
$address2 = $donorid['address2'];
$city = $donorid['city'];
$state = $donorid['state'];
$country = $donorid['country'];
$region = $donorid['region'];
// Alternative equipment location specified, get lat/lon for that as well...
if ($donorid['equip_address1'] && $donorid['equip_city'] && $donorid['equip_state']) {
$equip_address1 = $donorid['equip_address1'];
$equip_address2 = $donorid['equip_address2'];
$equip_city = $donorid['equip_city'];
$equip_state = $donorid['equip_state'];
$equip_country = $donorid['equip_country'];
$equip_region = $donorid['equip_region'];
}
unset($donorid);
$contact_array = true;
// Get address information for partners...
} elseif ($table == "partner_info" || $table == "partner_info_temp") {
$partner = get_partner_array($partnerid,$projectid,$locationid);
$org_name = $partner['org_name'];
$main_locationid = $partner['main_locationid'];
foreach ($partner['project_details'] as $project) {
if (is_array($project['locations'][$main_locationid])) {
$location = $project['locations'][$main_locationid];
$address1 = $location['address1'];
$address2 = $location['address2'];
$city = $location['city'];
$state = $location['state'];
$region = $location['region'];
$country = $location['country'];
if (preg_match("/United States/i",$country)) {
$zip = explode("-",$location['zip']);
$zip = $zip[0];
} else {
$zip = $location['zip'];
}
}
}
} else if ($table == "partner_locations") {
if (!$locationid) {
//$location_result = my_db_query("SELECT * FROM partner_locations WHERE (partnerid = {$partnerid}) AND (location_type like 'main')");
$location_result = my_db_query("SELECT partner_locations.* FROM partner_locations_link LEFT JOIN partner_locations ON partner_locations.id = partner_locations_link.locationid WHERE (partner_locations_link.partnerid = {$partnerid}) AND (partner_locations_link.projectid = '')");
} else {
//echo "\n";
$location_result = my_db_query("SELECT * FROM partner_locations WHERE (id = {$locationid})");
}
if (mysql_numrows($location_result)) {
$id = mysql_result($location_result,0,"id");
//echo "\n";
$link_result = my_db_query("SELECT * FROM `partner_locations_link` WHERE (`locationid` = {$id})");
if (mysql_numrows($link_result)) {
$projectid = mysql_result($link_result,0,"projectid");
}
if ($GLOBALS['find_loc']) {
$lat = mysql_result($location_result,0,"lat");
$lon = mysql_result($location_result,0,"lon");
echo "\n";
}
$address1 = mysql_result($location_result,0,"address1");
$address2 = mysql_result($location_result,0,"address2");
$city = mysql_result($location_result,0,"city");
$state = mysql_result($location_result,0,"state");
$country = mysql_result($location_result,0,"country");
$region = mysql_result($location_result,0,"region");
if (preg_match("/United States/i",$country)) {
$zip = explode("-",mysql_result($location_result,0,"zip"));
$zip = $zip[0];
} else {
$zip = mysql_result($location_result,0,"zip");
}
}
} else if ($table == "donor_info" || $table == "donor_info_temp") {
$donor_result = my_db_query("select id, donorid, name, addy1, addy2, city, state, zip, country, region, lat, lon from {$table} where (addy1 not like '' and city not like '' and zip not like '' and (donorid like '{$donorid}'))","{$database}");
$donor_num = mysql_numrows($donor_result);
if ($donor_num > 0) {
$id = mysql_result($donor_result,$i,"id");
$donorid = mysql_result($donor_result,$i,"donorid");
$name = mysql_result($donor_result,$i,"name");
$address1 = mysql_result($donor_result,$i,"addy1");
$address2 = mysql_result($donor_result,$i,"addy2");
$city = mysql_result($donor_result,$i,"city");
$state = mysql_result($donor_result,$i,"state");
$country = mysql_result($donor_result,$i,"country");
$region = mysql_result($donor_result,$i,"region");
if (preg_match("/United States/i",$country)) {
$zip = explode("-",mysql_result($donor_result,$i,"zip"));
$zip = $zip[0];
} else {
$zip = mysql_result($donor_result,$i,"zip");
}
$lat = mysql_result($donor_result,$i,"lat");
$lon = mysql_result($donor_result,$i,"lon");
}
// Determine whether to use the donor's address, the asset contact or an equipment contact address...
$asset_result = my_db_query("select * from asset_contact where donorid like '$donorid' and sessionid like '$sessionid'");
$asset_num = mysql_numrows($asset_result);
if ($asset_num > 0) {
$equip_loc = mysql_result($asset_result,0,"equip_loc");
if ($equip_loc == "asset_contact") {
$id = mysql_result($asset_result,$i,"id");
$address1 = mysql_result($asset_result,0,"addy1");
$address2 = mysql_result($asset_result,0,"addy2");
$city = mysql_result($asset_result,0,"city");
$state = mysql_result($asset_result,0,"state");
$zip = mysql_result($asset_result,0,"zip");
$country = mysql_result($asset_result,0,"country");
$region = mysql_result($asset_result,0,"region");
$lat = mysql_result($asset_result,0,"lat");
$lon = mysql_result($asset_result,0,"lon");
$table = "asset_contact";
}
}
// Equipment resides with the equipment contact...
if (($equip_loc == "equip_contact") || !$equip_loc) {
$equip_result = my_db_query("select * from equip_contact where donorid like '$donorid' and sessionid like '$sessionid'");
$equip_num = mysql_numrows($equip_result);
if ($equip_num > 0) {
$id = mysql_result($equip_result,$i,"id");
$address1 = mysql_result($equip_result,0,"addy1");
$address2 = mysql_result($equip_result,0,"addy2");
$city = mysql_result($equip_result,0,"city");
$state = mysql_result($equip_result,0,"state");
$zip = mysql_result($equip_result,0,"zip");
$country = mysql_result($equip_result,0,"country");
$region = mysql_result($equip_result,0,"region");
$lat = mysql_result($equip_result,0,"lat");
$lon = mysql_result($equip_result,0,"lon");
$table = "equip_contact";
}
}
}
//$GLOBALS['debug'] = true;
if ((!$lat || !$lon) || $update) {
$search_address = urlencode($address1) . ",+";
$search_city = urlencode($city) . ",+";
$search_state = urlencode($state);
$search_zip = urlencode($zip) . "+";
$search_country = urlencode($country);
$search_region = urlencode($region) . ",+";
if ($equip_address1 && $equip_city && ($equip_state || $equip_region)) {
$equip_search_address = urlencode($equip_address1) . ",+";
$equip_search_city = urlencode($equip_city) . ",+";
$equip_search_state = urlencode($equip_state);
$equip_search_zip = urlencode($equip_zip) . "+";
$equip_search_country = urlencode($equip_country);
$equip_search_region = urlencode($equip_region) . ",+";
}
// The Yahoo! Web Services request (5,000/IP/day)...
$yahoo_req = "http://where.yahooapis.com/geocode?location={$search_address}{$search_city}{$search_state}%20{$search_zip}&flags=P&appid=eeMHdi6s";
// Old Google (browser) Key...
//$key = "AIzaSyC3UIKTacidH10XUDu7ouzygy7B5xGfkdY";
// New browser key (doesn't seem necessary with v3?)...
$key = "AIzaSyCTQcPgpBM5NILpj74wC_F0-O27yT0sY2A";
// IP Server key...
//$key = "AIzaSyDO0irzkD90G1VuCi1bUzb6WPJWhBVsbfc";
if (preg_match("/United States/i",$country)) {
if ($GLOBALS['debug']) { echo "\n"; }
//$req1 = "https://maps.google.com/maps/api/geocode/json?sensor=false&key=AIzaSyCTQcPgpBM5NILpj74wC_F0-O27yT0sY2A&address=
$req1 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address}{$search_city}{$search_state}+{$search_zip}&key={$key}&sensor=false&random=" . rand();
if ($equip_search_address) {
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$equip_search_address}{$equip_search_city}{$equip_search_state}+{$equip_search_zip}&key={$key}&sensor=false&random=" . rand();
}
} else if (preg_match("/Canada/i",$country)) {
if ($GLOBALS['debug']) { echo "\n"; }
if ($search_region) {
$req1 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address}{$search_city}{$search_region}{$search_zip}{$search_country}&key={$key}&sensor=false&random=" . rand();
if ($equip_search_address) {
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$equip_search_address}{$equip_search_city}{$equip_search_region}{$equip_search_zip}{$equip_search_country}&key={$key}&sensor=false&random=" . rand();
}
} else {
$req1 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address}{$search_city}{$search_zip}{$search_country}&key={$key}&sensor=false&random=" . rand();
if ($equip_search_address) {
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$equip_search_address}{$equip_search_city}{$equip_search_zip}{$equip_search_country}&key={$key}&sensor=false&random=" . rand();
}
}
} else {
if ($GLOBALS['debug']) { echo "\n"; }
if ($search_region) {
$req1 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address}{$search_city}{$search_region}{$search_zip},+{$search_country}&key={$key}&sensor=false&random=" . rand();
if ($equip_search_address) {
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$equip_search_address}{$equip_search_city}{$equip_search_region}{$equip_search_zip},+{$equip_search_country}&key={$key}&sensor=false&random=" . rand();
}
} else {
$req1 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address}{$search_city}{$search_zip},+{$search_country}&key={$key}&sensor=false&random=" . rand();
if ($equip_search_address) {
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$equip_search_address}{$equip_search_city}{$equip_search_zip},+{$equip_search_country}&key={$key}&sensor=false&random=" . rand();
}
}
}
if ($GLOBALS['debug']) { echo "\n"; }
// Make the request (Yahoo)...
//$phpserialized = file_get_contents($req);
// Google Maps API v3 Service request (2,500/IP/day)...
$request = file_get_contents($req1);
$map_json = json_decode($request, true);
$GLOBALS['lat'] = $map_json['results'][0]['geometry']['location']['lat'];
$GLOBALS['lon'] = $map_json['results'][0]['geometry']['location']['lng'];
$GLOBALS['precision'] = $map_json['results'][0]['types'][0];
if ($GLOBALS['debug']) echo "\n";
if ($GLOBALS['debug']) echo "\n";
// Equipment address specified, find that...
if ($req2) {
$request = file_get_contents($req2);
$equip_map_json = json_decode($request, true);
$GLOBALS['equip_lat'] = $equip_map_json['results'][0]['geometry']['location']['lat'];
$GLOBALS['equip_lon'] = $equip_map_json['results'][0]['geometry']['location']['lng'];
$GLOBALS['equip_precision'] = $equip_map_json['results'][0]['types'][0];
if ($GLOBALS['debug']) echo "\n";
}
// Bad precision, try to get the address using the address2 field...
if (($GLOBALS['precision'] != "street_address" && $GLOBALS['precision'] != "premise" && $GLOBALS['precision'] != "subpremise") && $address2 && !$GLOBALS['find_loc']) {
$search_address = urlencode(trim($address2));
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address},+{$search_city}{$search_state}+{$search_zip}&key=&sensor=false&random=" . rand();
$request = file_get_contents($req2);
$map_json = json_decode($request, true);
$GLOBALS['lat'] = $map_json['results'][0]['geometry']['location']['lat'];
$GLOBALS['lon'] = $map_json['results'][0]['geometry']['location']['lng'];
$GLOBALS['precision'] = $map_json['results'][0]['types'][0];
if ($GLOBALS['debug']) { echo "\n"; }
if ($GLOBALS['debug']) { echo "\n"; }
if ($GLOBALS['debug']) echo "\n";
}
if ($equip_search_address && ($GLOBALS['equip_precision'] != "street_address" && $GLOBALS['equip_precision'] != "premise" && $GLOBALS['equip_precision'] != "subpremise")) {
$search_address = urlencode(trim($equip_address2));
$req2 = "https://maps.googleapis.com/maps/api/geocode/json?address={$search_address},+{$search_city}{$search_state}+{$search_zip}&key=&sensor=false&random=" . rand();
$request = file_get_contents($req2);
$equip_map_json = json_decode($request, true);
$GLOBALS['equip_lat'] = $equip_map_json['results'][0]['geometry']['location']['lat'];
$GLOBALS['equip_lon'] = $equip_map_json['results'][0]['geometry']['location']['lng'];
$GLOBALS['equip_precision'] = $equip_map_json['results'][0]['types'][0];
if ($GLOBALS['debug']) { echo "\n"; }
if ($GLOBALS['debug']) { echo "\n"; }
if ($GLOBALS['debug']) echo "\n";
}
// Parse the serialized response (Yahoo)...
//$phparray = unserialize($phpserialized);
// Pull Yahoo data from array...
//$precision = $phparray['ResultSet']['Result']['precision'];
//$lon = $phparray['ResultSet']['Result']['Longitude'];
//$lat = $phparray['ResultSet']['Result']['Latitude'];
// Only update the database if we have street or address precision and update was called for...
if (($GLOBALS['precision'] == "street_address" || $GLOBALS['precision'] == "premise" || $GLOBALS['precision'] == "subpremise") && $GLOBALS['lat'] && $GLOBALS['lon'] && !$GLOBALS['find_loc'] && $update) {
if ($GLOBALS['debug']) { echo "\n"; }
my_db_query("update {$table} set lat = '{$GLOBALS['lat']}', lon = '{$GLOBALS['lon']}' where id like '$id'","{$database}");
} else if (!$contact_array && $table && ($table_name == "partner_locations")) {
if ($GLOBALS['debug']) { echo "\n"; }
my_db_query("update {$table} set `set_manually` = '', `lat` = '', `lon` = '' where id like '$id'","{$database}");
}
} else {
echo "\n";
$GLOBALS['lat'] = $lat;
$GLOBALS['lon'] = $lon;
}
// Return geo data (Yahoo)...
//return $phparray;
// Return geo data (Google)...
return $map_json;
}
function get_donor_array($donorid, $sessionid = "", $use_temp_data = false) {
if ($use_temp_data) { $db = "cristina_tmp"; } else { $db = "cristina"; }
$donor_result = my_db_query("SELECT * FROM donor_info WHERE donorid = $donorid","{$db}");
$donor_info = mysql_fetch_array($donor_result);
// echo "Donor Record Found: {$donor_info['name']}\n";
$donor['donor_id'] = $donorid;
$donor['donor_name'] = $donor_info['name'];
$donor['donor_company'] = $donor_info['company'];
$donor['donor_email'] = $donor_info['email'];
$donor['donor_addy1'] = $donor_info['addy1'];
$donor['donor_addy2'] = $donor_info['addy2'];
$donor['donor_zip'] = $donor_info['zip'];
$donor['donor_city'] = $donor_info['city'];
$donor['donor_state'] = $donor_info['state'];
$donor['donor_country'] = $donor_info['country'];
$donor['donor_region'] = $donor_info['region'];
$donor['donor_phone_area'] = $donor_info['area'];
$donor['donor_phone_prefix'] = $donor_info['phone_prefix'];
$donor['donor_phone_suffix'] = $donor_info['phone_suffix'];
$donor['donor_phone_ext'] = $donor_info['phone_ext'];
$donor['donor_fax_area'] = $donor_info['fax_area'];
$donor['donor_fax_prefix'] = $donor_info['fax_prefix'];
$donor['donor_fax_suffix'] = $donor_info['fax_suffix'];
$donor['lat'] = $donor_info['lat'];
$donor['lon'] = $donor_info['lon'];
$donor['donor_phone'] = "({$donor_info['area']}) {$donor_info['phone_prefix']}-{$donor_info['phone_suffix']}";
if ($donor_info['fax_area'] && $donor_info['fax_prefix'] && $donor_info['fax_suffix']) {
$donor['donor_fax'] = "({$donor_info['fax_area']}) {$donor_info['fax_prefix']}-{$donor_info['fax_suffix']}";
} else {
$donor['donor_fax'] = "";
}
//
// generate possibly helpful contact info text
//
$donor['donor_contact_text'] = "{$donor['donor_name']}\n";
if ($donor['donor_company']) {
$donor['donor_contact_text'] .= "{$donor['donor_company']}\n";
}
$donor['donor_contact_text'] .= "{$donor['donor_addy1']}\n";
if ($donor['donor_addy2']) {
$donor['donor_contact_text'] .= "{$donor['donor_addy2']}\n";
}
$donor['donor_contact_text'] .= "{$donor['donor_city']}, {$donor['donor_state']} {$donor['donor_zip']}\n";
if ($donor['donor_region']) {
$donor['donor_contact_text'] .= "{$donor['donor_region']}\n";
}
$donor['donor_contact_text'] .= "{$donor['donor_country']}\n";
$donor['donor_contact_text'] .= "\nPhone: {$donor['donor_phone']}\n";
if ($donor['donor_fax']) {
$donor['donor_contact_text'] .= "Fax: {$donor['donor_fax']}\n";
}
if ($donor['donor_email']) {
$donor['donor_contact_text'] .= "Email: {$donor['donor_email']}\n";
}
// Which staff member typically deals with this US donor?
$region_result = my_db_query("select user from regions where state = '{$donor['donor_state']}'");
$region_num = mysql_numrows($region_result);
if ($region_num > 0) {
$user = mysql_fetch_assoc($region_result);
$staff_result = my_db_query("select name, extension from dtap_settings where user = '{$user['user']}'");
$staff_num = mysql_numrows($staff_result);
if ($staff_num > 0) {
$staff = mysql_fetch_assoc($staff_result);
$donor['staff_user'] = $user['user'];
$donor['staff_name'] = $staff['name'];
$donor['staff_ext'] = $staff['extension'];
}
// Must not be in the US...
} else {
// Default to Nancy for International partners...
$donor['staff_user'] = "nancy";
$donor['staff_name'] = "Nancy Cortez";
$donor['staff_ext'] = "364";
}
// No session specified, get all past donation information...
if ($sessionid == "") {
$session_where = "";
} else {
$session_where = "AND (`sessionid` like '{$sessionid}')";
}
if (!$use_temp_data) {
$db = "cristina";
} else {
$db = "cristina_tmp";
}
// Get basic session information from donation_summary...
//echo "my_db_query(\"select distinct sessionid, status, DATE(donation_summary.match_date) as match_date, DATE(donation_summary.placement_date) as placement_date, DATE(donation_summary.date) as pledge_date from donation_summary where donorid = '{$donorid}' {$session_where}\",$db);\n";
$sessions_result = my_db_query("select distinct `projectid`, `locationid`, `will_ship`, `region_code`, sessionid, status, DATE(donation_summary.match_date) as match_date, DATE(donation_summary.placement_date) as placement_date, DATE(donation_summary.date) as pledge_date from donation_summary where donorid = '{$donorid}' {$session_where}",$db);
$sessions_num = mysql_numrows($sessions_result);
while ($session = mysql_fetch_assoc($sessions_result)) {
$donor['sessionids'][$session['sessionid']] = $session;
$session_result = my_db_query("SELECT `table_name`, `itemid`, `option_level`, `status` FROM `donation_summary` WHERE (`donorid` = {$donorid}) AND (`sessionid` like '{$session['sessionid']}')",$db);
if (mysql_numrows($session_result)) {
while ($items = mysql_fetch_assoc($session_result)) {
if (!is_array(${$items['table_name']})) {
$options_result = my_db_query("SELECT * FROM `form_options` WHERE (`table_name` like '{$items['table_name']}') AND (`display_when` = {$items['option_level']}) AND (`hidden` < 1) ORDER BY `field_name`,`sort_order` ASC");
if (mysql_numrows($options_result)) {
while ($options = mysql_fetch_assoc($options_result)) {
${$items['table_name']}[$options['field_name']][$options['option_value']] = $options['option_text'];
}
}
}
//echo " |<\/p>|<\/div>/i", $resource['article_text'])) {
$type = "html";
} else {
$type = "text";
}
$result_category = my_db_query("SELECT category FROM resource_categories WHERE id={$resource['category']}");
if (mysql_num_rows($result_category) > 0) {
$category_info = mysql_fetch_assoc($result_category);
$category = $category_info['category'];
}
$result_subcategory = my_db_query("SELECT subcategory FROM resource_subcategories WHERE id={$resource['subcategory']}");
if (mysql_num_rows($result_subcategory) > 0) {
$subcategory_info = mysql_fetch_assoc($result_subcategory);
$subcategory = $subcategory_info['subcategory'];
}
if ($format == "partial") {
$authdate = "Written: " . date("M j, Y", strtotime($resource['date_created'])) . " by " . stripslashes(trim($resource['author'])) . "\n";
echo " \n";
//echo " Originally Published: " . date("M j, Y", strtotime($resource['date_published'])) . " by " . trim(stripslashes($resource['author'])) . " at {$resource['publisher']} The National Cristina Foundation was founded by Yvette Marrin and David Bruce McMahan and for more than {$years} years has been Linking Life to its Promise. Originally Published: " . date("M j, Y", strtotime($resource['date_published'])) . " by " . trim(stripslashes($resource['author'])) . " at {$resource['publisher']} The National Cristina Foundation was founded by Yvette Marrin and David Bruce McMahan and for more than {$years} years has been Linking Life to its Promise. |<\/p>|<\/div>/i", $resource['feedback_text'])) {
$type = "html";
} else {
$type = "text";
}
if ($format == "partial") {
$authdate = "Provided: " . date("M j, Y", strtotime($resource['date_provided'])) . " by " . trim($resource['author']) . "\n";
echo " \n";
//echo " |<\/p>|<\/div>/i", $resource['blog_text'])) {
$type = "html";
} else {
$type = "text";
}
if ($format == "partial") {
$authdate = "Written: " . date("M j, Y", strtotime($resource['date_created'])) . " by " . stripslashes(trim($resource['author'])) . "\n";
echo " \n";
} elseif ($format == "full") {
echo " Originally Published: " . date("M j, Y", strtotime($resource['date_published'])) . " by " . trim(stripslashes($resource['author'])) . " at {$resource['publisher']} The National Cristina Foundation was founded by Yvette Marrin and David Bruce McMahan and for more than {$years} years has been Linking Life to its Promise. Originally Published: " . date("M j, Y", strtotime($resource['date_published'])) . " by " . trim(stripslashes($resource['author'])) . " at {$resource['publisher']} The National Cristina Foundation was founded by Yvette Marrin and David Bruce McMahan and for more than {$years} years has been Linking Life to its Promise. \n";
}
if (mysql_num_rows($result) == 0) {
echo "No Comments Found... Be the first to leave a comment! \n";
} else {
?>
') && !stristr($body_html, ' '))) {
$is_html = true;
}
*/
$is_html = false;
if ($body_html) {
$is_html = true;
}
//
// line out the envelope recipients
//
$recipients_tmp = stripslashes($to);
if ($cc != "") $recipients_tmp .= "," . $cc;
if ($bcc != "") $recipients_tmp .= "," . $bcc;
preg_match_all("([a-zA-Z0-9._'-]*@[a-zA-Z0-9.-]*\.[a-zA-Z0-9.-]*)",$recipients_tmp,$regs);
$recipients = implode(",", $regs[0]);
if (!$is_html && (trim($attachments[0]) != "" || trim($attachments[1]))) { // it's a plain text message...
$boundary_1 = "----=_NextPart_000_0001_" . $hexdate . ".8DCC78B0";
$header_content_type = "multipart/mixed;\n boundary=\"{$boundary_1}\"";
$body = "This is a multi-part message in MIME format.\n\n";
$body .= "--{$boundary_1}\nContent-Type: text/plain;\n charset=\"us-ascii\"\nContent-Transfer-Encoding: 7bit\n\n";
$body .= $body_text . "\n\n";
//
// attach any attachments passed in
//
for ($i = 0; $i
Sent headers:";
// print_r($headers);
// echo "
\n";
// echo "
Sent body:" . htmlentities($body) . "
\n";
//
// send the message
//
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($recipients, $headers, $body);
if (PEAR::isError($mail)) {
$GLOBALS['smtp_response'] = $mail->getMessage();
return false;
} else {
$GLOBALS['smtp_response'] = "Message successfully sent to: " . htmlentities($recipients);
return true;
}
}}
function my_get_headers($url) {
$url_info=parse_url($url);
if (isset($url_info['scheme']) && $url_info['scheme'] == 'https') {
$port = 443;
@$fp=fsockopen('ssl://'.$url_info['host'], $port, $errno, $errstr, 10);
} else {
$port = isset($url_info['port']) ? $url_info['port'] : 80;
@$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 10);
}
if($fp) {
stream_set_timeout($fp, 10);
$head = "HEAD ".@$url_info['path']."?".@$url_info['query'];
$head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n";
fputs($fp, $head);
while(!feof($fp)) {
if($header=trim(fgets($fp, 1024))) {
$sc_pos = strpos( $header, ':' );
if( $sc_pos === false ) {
$headers['status'] = $header;
} else {
$label = substr( $header, 0, $sc_pos );
$value = substr( $header, $sc_pos+1 );
$headers[strtolower($label)] = trim($value);
}
}
}
return $headers;
}
else {
return false;
}
}
/**universal
* Encoder une chaine compatible "ENCODING=QUOTED-PRINTABLE" - cette chaine est décodable avec la fonction "quoted_printable_decode()"
* ex: quoted_printable_encode(ut8_encode("c'est quand l'été ?")) -> "c'est quand l'=C3=A9t=C3=A9 ?"
*
* @author Thomas Pequet / Memotoo.com
* @version 1.1
* @param string:string Chaine
* @return Chaine encodée
*/
if (!function_exists('quoted_printable_encode')) {
function quoted_printable_encode($string) {
// Fonction qui ajoute au tableau de valeurs un "=" devant
if (!function_exists("array_values_quoted_printable"))
{
function array_values_quoted_printable($tab)
{
$tabValues = array_values($tab);
for ($i=0;$i" . print_r(${$items['table_name']},true) . "
\n";
$item_result = my_db_query("SELECT * FROM `{$items['table_name']}` WHERE (`id` = {$items['itemid']})",$db);
if (mysql_numrows($item_result)) {
$key = $items['table_name'] . "-" . $items['itemid'];
$item = mysql_fetch_assoc($item_result);
foreach ($item as $field => $value) {
if (is_numeric($value) && ${$items['table_name']}[$field][$value]) {
$value = ${$items['table_name']}[$field][$value];
}
$donor['sessionids'][$session['sessionid']]['items'][$key][$field] = $value;
}
}
}
}
}
$asset = array();
$equip = array();
// Get all equip_contact entries for this donor...
$equip_result = my_db_query("SELECT * FROM equip_contact WHERE donorid = '$donorid' {$session_where}");
while ($equip_info = mysql_fetch_array($equip_result,MYSQLI_ASSOC)) {
$this_sessionid = $equip_info['sessionid'];
// Generate the unified phone field...
if ($equip_info['area'] && $equip_info['phone_prefix'] && $equip_info['phone_suffix']) {
$equip_info['phone'] = "({$equip_info['area']}) {$equip_info['phone_prefix']}-{$equip_info['phone_suffix']}";
} else {
$equip_info['phone'] = "";
}
// Generate the unified fax field...
if ($equip_info['fax_area'] && $equip_info['fax_prefix'] && $equip_info['fax_suffix']) {
$equip_info['fax'] = "({$equip_info['fax_area']}) {$equip_info['fax_prefix']}-{$equip_info['fax_suffix']}";
} else {
$equip_info['fax'] = "";
}
$equip_keys = array_keys($equip_info);
$equip_values = array_values($equip_info);
// Go through all fields and prepend "equip_" to the field name...
for ($a = 0;$a < sizeof($equip_keys);$a++) {
$new_key = "equip_" . $equip_keys[$a];
$equip[$this_sessionid][$new_key] = $equip_values[$a];
}
// If this session has asset_contact data, merge with it and update the master array...
if (array_key_exists($this_sessionid, $asset)) {
$donor['sessionids'][$this_sessionid] = array_merge_recursive($asset[$this_sessionid], $equip[$this_sessionid]);
} else {
$donor['sessionids'][$this_sessionid] = array_merge_recursive($donor['sessionids'][$this_sessionid],$equip[$this_sessionid]);
}
// Overwrite main donor record lat/lon with equipment address coordinates...
if ($equip_info['lat'] && $equip_info['lon']) {
$donor['lat'] = $equip_info['lat'];
$donor['lon'] = $equip_info['lon'];
}
}
// Get all asset_contact entries for this donor...
$asset_result = my_db_query("SELECT * FROM asset_contact WHERE donorid = '$donorid' {$session_where}");
$asset_info = mysql_fetch_array($asset_result);
while ($asset_info = mysql_fetch_array($asset_result,MYSQLI_ASSOC)) {
$this_sessionid = $asset_info['sessionid'];
// Generate the unified phone field...
if ($asset_info['area'] && $asset_info['phone_prefix'] && $asset_info['phone_suffix']) {
$asset_info['phone'] = "({$asset_info['area']}) {$asset_info['phone_prefix']}-{$asset_info['phone_suffix']}";
} else {
$asset_info['phone'] = "";
}
// Generate the unified fax field...
if ($asset_info['fax_area'] && $asset_info['fax_prefix'] && $asset_info['fax_suffix']) {
$asset_info['fax'] = "({$asset_info['fax_area']}) {$asset_info['fax_prefix']}-{$asset_info['fax_suffix']}";
} else {
$asset_info['fax'] = "";
}
$asset_keys = array_keys($asset_info);
$asset_values = array_values($asset_info);
// Go through all fields and prepend "asset_" to the field name...
for ($a = 0;$a < sizeof($asset_keys);$a++) {
$new_key = "asset_" . $asset_keys[$a];
$asset[$this_sessionid][$new_key] = $asset_values[$a];
}
// If this session has equip_contact data, merge with it and update the master array...
if (array_key_exists($this_sessionid, $equip)) {
$donor['sessionids'][$this_sessionid] = array_merge_recursive($asset[$this_sessionid], $equip[$this_sessionid]);
} else {
if (!is_array($donor['sessionids'][$this_sessionid])) $donor['sessionids'][$this_sessionid] = array();
$donor['sessionids'][$this_sessionid] = array_merge_recursive($donor['sessionids'][$this_sessionid],$asset[$this_sessionid]);
}
}
// Create and/or pad any remaining sessions...
/*
while ($this_session = mysql_fetch_array($sessions_result)) {
if (!is_array($donor['sessionids'])) {
$donor['sessionids'] = array();
}
if (!array_key_exists($this_session['sessionid'],$donor['sessionids'])) {
$donor['sessionids'][$this_session['sessionid']] = array();
}
$donor['sessionids'][$this_session['sessionid']]['pledge_date'] = $this_session['pledge_date'];
$donor['sessionids'][$this_session['sessionid']]['match_date'] = $this_session['match_date'];
$donor['sessionids'][$this_session['sessionid']]['placement_date'] = $this_session['placement_date'];
$donor['sessionids'][$this_session['sessionid']]['status'] = $this_session['status'];
}
*/
// Look for any donations begun but not complete by this donor...
//} else if ($use_temp_data) {
$tmp_donor_result = my_db_query("SELECT * FROM `donor_info` WHERE (TO_DAYS(NOW()) - TO_DAYS(`submission_date`) < 180) and (`donorid` like '{$donor_info['donorid']}' || `email` like '" . mysql_escape_string($donor_info['email']) . "') order by `submission_date` desc","cristina_tmp");
while ($donations = mysql_fetch_assoc($tmp_donor_result)) {
$donor['in_progress'][$donations['sessionid']] = $donations;
}
// sessionid was passed, get specific info...
/*
$equip_contact_exists = false;
if ($sessionid != "") {
$equip_result = my_db_query("SELECT * FROM equip_contact WHERE donorid = '$donorid' and sessionid = '$sessionid'");
$equip_num = mysql_numrows($equip_result);
if ($equip_num > 0) {
$equip_contact_exists = true;
$equip_info = mysql_fetch_array($equip_result);
$donor['equip_name'] = $equip_info['name'];
$donor['equip_addy1'] = $equip_info['addy1'];
$donor['equip_addy2'] = $equip_info['addy2'];
$donor['equip_zip'] = $equip_info['zip'];
$donor['equip_city'] = $equip_info['city'];
$donor['equip_state'] = $equip_info['state'];
$donor['equip_country'] = $equip_info['country'];
$donor['equip_region'] = $equip_info['region'];
$donor['equip_phone'] = "({$equip_info['area']}) {$equip_info['phone_prefix']}-{$equip_info['phone_suffix']}";
if ($equip_info['fax_area'] && $equip_info['fax_prefix'] && $equip_info['fax_suffix']) {
$donor['equip_fax'] = "({$equip_info['fax_area']}) {$equip_info['fax_prefix']}-{$equip_info['fax_suffix']}";
} else {
$donor['equip_fax'] = "";
}
}
}
*/
// Why are we doing this?
/*
if (!$equip_contact_exists) {
$donor['equip_name'] = $donor['donor_name'];
$donor['equip_addy1'] = $donor['donor_addy1'];
$donor['equip_addy2'] = $donor['donor_addy2'];
$donor['equip_zip'] = $donor['donor_zip'];
$donor['equip_city'] = $donor['donor_city'];
$donor['equip_state'] = $donor['donor_state'];
$donor['equip_country'] = $donor['donor_country'];
$donor['equip_region'] = $donor['donor_region'];
$donor['equip_phone'] = $donor['donor_phone'];
$donor['equip_fax'] = $donor['donor_fax'];
}
*/
//echo "\n";
return $donor;
}
function get_partner_search_query($preset = '', $status = 'active', $state = '', $date_begin = '', $date_end = '') {
if ($preset != "") {
$result = my_db_query("SELECT * FROM search_presets WHERE id = $preset");
if (mysql_num_rows($result) != 0) {
$query_info = mysql_fetch_assoc($result);
$query = $query_info['query'];
} else {
$query = "SELECT DISTINCT partner_info.id as id,partner_info.org_name as org_name FROM partner_info LEFT JOIN partner_locations ON partner_info.id = partner_locations.partnerid WHERE partner_info.status LIKE '-STATUS-' -STATE- ORDER BY partner_info.id";
}
} else {
$query = "SELECT DISTINCT partner_info.id as id,partner_info.org_name as org_name FROM partner_info LEFT JOIN partner_locations ON partner_info.id = partner_locations.partnerid WHERE partner_info.status LIKE '-STATUS-' -STATE- ORDER BY partner_info.id";
}
// status
$query = str_replace("-STATUS-", $status, $query);
// local (state/prov)
if ($state != "") {
$state_arr = split(",", $state);
unset($state);
foreach ($state_arr as $this_state) {
if (trim($this_state) != "") {
if ($state != "") $state .= ",";
$state .= "'{$this_state}'";
}
}
if ($state != "") {
$state_str = "AND partner_locations.state IN ({$state})";
}
}
$query = str_replace("-STATE-", $state_str, $query);
// date begin
if ($date_begin != "") {
$date_begin_epoch = strtotime($date_begin);
if ($query_info['date_format'] == "epoch") $this_date = $date_begin_epoch;
else $this_date = date("{$query_info['date_format']}", $date_begin_epoch);
}
$query = str_replace("-DATE_BEGIN-", $this_date, $query);
// date end
if ($date_end != "") {
$date_end_epoch = strtotime($date_end);
if ($query_info['date_format'] == "epoch") $this_date = $date_end_epoch;
else $this_date = date("{$query_info['date_format']}", $date_end_epoch);
}
$query = str_replace("-DATE_END-", $this_date, $query);
return $query;
}
function get_partner_array($partnerid, $projectid = "", $locationid = "", $db = "cristina") {
// Just die if they try passing in a non-numeric partnerID or projectid...
if (!is_numeric($partnerid)) exit;
if ($projectid) {
if (!is_numeric($projectid) && ($projectid != "all")) exit;
}
$result = my_db_query("SELECT * FROM `partner_info` WHERE (`id` = '" . mysql_escape_string($partnerid) . "')", $db);
$partner_num = mysql_numrows($result);
if ($partner_num > 0) {
$partner_info = mysql_fetch_array($result);
// echo "Partner Record Found: {$partner_info['org_name']}\n";
$partner['partnerid'] = $partner_info['id'];
$partner['partner_id'] = $partner_info['id'];
$partner['partner_parent_id'] = $partner_info['parent_id'];
if ($db == "cristina_tmp") {
$partner['signup_name'] = $partner_info['signup_name'];
$partner['signup_email'] = $partner_info['signup_email'];
}
$partner['partner_type'] = $partner_info['type'];
$partner['org_type'] = $partner_info['org_type'];
$partner['location_type'] = $partner_info['location_type'];
$partner['facility_type'] = $partner_info['facility_type'];
$partner['service_sites'] = $partner_info['service_sites'];
$partner['ages_served'] = $partner_info['ages_served'];
$partner['served_annually'] = $partner_info['served_annually'];
$partner['staffing_totals'] = $partner_info['staffing_totals'];
$partner['partner_status'] = $partner_info['status'];
$partner['status'] = $partner_info['status'];
$partner['quick_summary_a'] = $partner_info['quick_summary_a'];
$partner['quick_summary_b'] = $partner_info['quick_summary_b'];
$partner['quick_summary_c'] = $partner_info['quick_summary_c'];
$partner['quick_summary_d'] = $partner_info['quick_summary_d'];
$partner['quick_summary_e'] = $partner_info['quick_summary_e'];
$partner['hold_date'] = $partner_info['hold_date'];
$partner['partner_name'] = $partner_info['org_name'];
$partner['org_name'] = $partner_info['org_name'];
$partner['partner_addy1'] = $partner_info['address1'];
$partner['partner_addy2'] = $partner_info['address2'];
$partner['partner_city']= $partner_info['city'];
$partner['partner_state'] = $partner_info['state'];
$partner['partner_region'] = $partner_info['region'];
$partner['partner_zip'] = $partner_info['zip'];
$partner['partner_country'] = $partner_info['country'];
//$partner['partner_email'] = $partner_info['email'];
$partner['partner_url'] = $partner_info['url'];
$partner['member_since'] = $partner_info['member_since'];
$partner['member_since_month'] = $partner_info['member_since_month'];
$partner['member_since_day'] = $partner_info['member_since_day'];
$partner['member_since_year'] = $partner_info['member_since_year'];
if ($partner_info['member_since_month'] && $partner_info['member_since_day'] && $partner_info['member_since_year']) {
$partner['member_since_text'] = date("F jS, Y", mktime(0, 0, 0, $partner_info['member_since_month'], $partner_info['member_since_day'], $partner_info['member_since_year']));
} else if ($partner['member_since']) {
$partner['member_since_year'] = substr($partner['member_since'], 0, 4);
$partner['member_since_month'] = substr($partner['member_since'], 4, 2);
$partner['member_since_day'] = substr($partner['member_since'], 6, 2);
if ($partner['member_since_year'] && $partner['member_since_month'] && $partner['member_since_day']) {
$partner['member_since_text'] = date("F jS, Y", mktime(0, 0, 0, $partner['member_since_month'], $partner['member_since_day'], $partner['member_since_year']));
}
}
$partner['priority'] = $partner_info['priority'];
$partner['rating'] = $partner_info['rating'];
$partner['mission'] = $partner_info['mission'];
$partner['staff_full_time'] = $partner_info['staff_full_time'];
$partner['staff_part_time'] = $partner_info['staff_part_time'];
$partner['staff_voluntary'] = $partner_info['staff_voluntary'];
$partner['training_support'] = $partner_info['training_support'];
$partner['submit_date'] = $partner_info['submit_date'];
$partner['last_updated'] = $partner_info['last_updated'];
$partner['last_donation'] = $partner_info['last_donation'];
$partner['staff_comment'] = $partner_info['staff_comment'];
$partner['AoP_checked'] = $partner_info['AoP_checked'];
$partner['501c3_checked'] = $partner_info['501c3_checked'];
$partner['501c3_upload'] = $partner_info['501c3_upload'];
$partner['501c3_desc'] = $partner_info['501c3_desc'];
$partner['refurbisher'] = $partner_info['refurbisher'];
$partner['recycler'] = $partner_info['recycler'];
if ($db == "cristina_tmp") {
$partner['site_origin'] = $partner_info['site_origin'];
$partner['issued_partnerid'] = $partner_info['issued_partnerid'];
$files_result = my_db_query("SELECT `501c3_upload` FROM `partner_info` WHERE (`id` = '" . mysql_escape_string($partnerid) . "')", "cristina_tmp");
if (mysql_numrows($files_result)) {
$existing_result = mysql_fetch_assoc($files_result);
$existing_files = explode("|",$existing_result['501c3_upload']);
foreach ($existing_files as $fileid) {
if ($lookup_list) $lookup_list .= ",";
$lookup_list .= "'{$fileid}'";
}
$filedata_result = my_db_query("SELECT * FROM `501c3_uploads` WHERE (`partnerid` = '" . mysql_escape_string($partnerid) . "') AND (`id` IN ({$lookup_list}))");
if (mysql_numrows($filedata_result)) {
while ($filedata = mysql_fetch_assoc($filedata_result)) {
$partner['501c3_files'][$filedata['id']] = $filedata['filename'];
if ($file_list) $file_list .= "|";
$file_list .= "{$filedata['id']}";
}
}
$partner['501c3_upload'] = $file_list;
my_db_query("UPDATE `partner_info` SET `501c3_upload` = '{$file_list}' WHERE (`id` = '" . mysql_escape_string($partnerid) . "')", "cristina_tmp");
}
$partner['will_fax'] = $partner_info['will_fax'];
}
$partner['ref_num'] = $partner_info['ref_num'];
$partner['tax_id'] = $partner_info['tax_id'];
$partner['updated_when'] = $partner_info['updated_when'];
$partner['updated_what'] = $partner_info['updated_what'];
$partner['placement_contact'] = $partner_info['placement_contact'];
$partner['lat'] = $location['lat'];
$partner['lon'] = $location['lon'];
// Get Award of Property agreement...
$aop_terms_result = my_db_query("SELECT * FROM `aop_terms` WHERE (`partnerid` = '" . mysql_escape_string($partnerid) . "') ORDER BY `id` DESC LIMIT 1");
if (mysql_numrows($aop_terms_result)) {
$aop_terms = mysql_fetch_assoc($aop_terms_result);
}
$partner['aop_terms'] = $aop_terms;
// Get memberships for this partner...
$memberships_result = my_db_query("SELECT `memberships`.*, `memberships_scopes`.`name` as `membership`, `memberships_scopes`.`desc` as 'membership_desc' FROM `memberships`, `memberships_scopes` WHERE (`memberships`.`scopeid` = `memberships_scopes`.`id`) AND (`memberships`.`member_table` = 'partner_info') AND (`memberships`.`member_id` = " . mysql_real_escape_string($partnerid) . ")");
if (mysql_numrows($memberships_result)) {
while ($membership = mysql_fetch_assoc($memberships_result)) {
$partner['memberships'][$membership['scopeid']] = $membership;
}
}
// Get phpBB3 user accounts tied to this partner...
if ($db == "cristina") {
$phpbb_result = my_db_query("SELECT * FROM `partner_passport_link` WHERE (`partnerid` = {$partnerid})");
// Generate single WHERE statement to get name/email for users...
while ($users = mysql_fetch_assoc($phpbb_result)) {
if ($where) { $where .= " or "; }
$where .= "(user_id = {$users['phpbb_user_id']})";
}
// Get array of phpbb user information...
if ($where) {
$phpbb_result = my_db_query("SELECT `user_id`, `username`, `user_email` from `users` WHERE {$where}", "phpbb3");
if (mysql_numrows($phpbb_result)) {
while ($phpbb_users = mysql_fetch_assoc($phpbb_result)) {
$passports[strtolower($phpbb_users['user_email'])] = $phpbb_users['user_id'];
$partner['passports'][$phpbb_users['user_id']] = $phpbb_users;
}
}
}
}
if ($partner_info['phone_area'] && $partner_info['phone_prefix'] && $partner_info['phone_suffix']) {
$partner['partner_phone_area'] = $partner_info['phone_area'];
$partner['partner_phone_prefix'] = $partner_info['phone_prefix'];
$partner['partner_phone_suffix'] = $partner_info['phone_suffix'];
$partner['partner_phone_ext'] = $partner_info['phone_ext'];
$partner['partner_phone'] = "({$partner_info['phone_area']}) {$partner_info['phone_prefix']}-{$partner_info['phone_suffix']}";
if ($partner_info['phone_ext'] != "") { $partner['partner_phone'] .= " x " . $partner_info['phone_ext']; }
}
if ($partner_info['fax_area'] && $partner_info['fax_prefix'] && $partner_info['fax_suffix']) {
$partner['partner_fax_area'] = $partner_info['fax_area'];
$partner['partner_fax_prefix'] = $partner_info['fax_prefix'];
$partner['partner_fax_suffix'] = $partner_info['fax_suffix'];
$partner['partner_fax'] = "({$partner_info['fax_area']}) {$partner_info['fax_prefix']}-{$partner_info['fax_suffix']}";
$partner['placement_fax'] = "({$partner_info['fax_area']}) {$partner_info['fax_prefix']}-{$partner_info['fax_suffix']}";
}
//
// grab all the contacts
//
$contact_result = my_db_query("SELECT * FROM `partner_contacts` WHERE partnerid = {$partner_info['id']}", $db);
while ($contact_info = mysql_fetch_assoc($contact_result)) {
$all_contacts[$contact_info['id']] = $contact_info;
// Insert admin/director as top-level elements...
if ($contact_info['contact_type'] == "admin" || $contact_info['contact_type'] == "director") {
$partner['partner_contacts'][] = $contact_info['id'];
$type_keys = array("{$contact_info['contact_type']}_name" => "name","{$contact_info['contact_type']}_title" => "title","{$contact_info['contact_type']}_phone_area" => "phone_area","{$contact_info['contact_type']}_phone_prefix" => "phone_prefix","{$contact_info['contact_type']}_phone_suffix" => "phone_suffix","{$contact_info['contact_type']}_phone_ext" => "phone_ext","{$contact_info['contact_type']}_fax_area" => "fax_area","{$contact_info['contact_type']}_fax_prefix" => "fax_prefix","{$contact_info['contact_type']}_fax_suffix" => "fax_suffix","{$contact_info['contact_type']}_email" => "email");
$contact_key = "partner_contact_" . $contact_info['id'];
$partner[$contact_key]['contact_type'] = $contact_info['contact_type'];
foreach($type_keys as $type_key => $key) {
// This sets things like ['director_name'] and ['admin_phone_prefix'] in the main partner array...
$partner[$type_key] = $contact_info[$key];
// This sets the contactid-specific ['partner_contact_contactid'] -> ['contact_name'] entries...
$field_key = "contact_" . $key;
$partner[$contact_key][$field_key] = $contact_info[$key];
}
if ($passports[strtolower($contact_info['email'])]) {
$partner[$contact_key]['contact_phpbb_user'] = $passports[strtolower($contact_info['email'])];
}
$contactid_key = "{$contact_info['contact_type']}_contactid";
$partner[$contactid_key] = $contact_info['id'];
if ($partner['director_phone_area'] && $partner['director_phone_prefix'] && $partner['director_phone_suffix']) {
$partner['director_phone'] = "({$partner['director_phone_area']}) {$partner['director_phone_prefix']}-{$partner['director_phone_suffix']}";
if ($partner['director_phone_ext'] != "") { $partner['director_phone'] .= " x " . $partner['director_phone_ext']; }
}
if ($partner['director_fax_area'] && $partner['director_fax_prefix'] && $partner['director_fax_suffix']) {
$partner['director_fax'] = "({$partner['director_fax_area']}) {$partner['director_fax_prefix']}-{$partner['director_fax_suffix']}";
if ($partner['director_fax_ext'] != "") { $partner['director_fax'] .= " x " . $partner['director_fax_ext']; }
}
if ($partner['admin_phone_area'] && $partner['admin_phone_prefix'] && $partner['admin_phone_suffix']) {
$partner['admin_phone'] = "({$partner['admin_phone_area']}) {$partner['admin_phone_prefix']}-{$partner['admin_phone_suffix']}";
if ($partner['admin_phone_ext'] != "") { $partner['admin_phone'] .= " x " . $partner['admin_phone_ext']; }
}
if ($partner['admin_fax_area'] && $partner['admin_fax_prefix'] && $partner['admin_fax_suffix']) {
$partner['admin_fax'] = "({$partner['admin_fax_area']}) {$partner['admin_fax_prefix']}-{$partner['admin_fax_suffix']}";
if ($partner['admin_fax_ext'] != "") { $partner['admin_fax'] .= " x " . $partner['admin_fax_ext']; }
}
// Other contacts...
} else {
$array_key = "partner_contact_" . $contact_info['id'];
$partner['partner_contacts'][] = $contact_info['id'];
$partner[$array_key]['contact_name'] = $contact_info['name'];
$partner[$array_key]['contact_title'] = $contact_info['title'];
$partner[$array_key]['contact_email'] = $contact_info['email'];
$partner[$array_key]['contact_addy1'] = $contact_info['address_line1'];
$partner[$array_key]['contact_addy2'] = $contact_info['address_line2'];
$partner[$array_key]['contact_city'] = $contact_info['city'];
$partner[$array_key]['contact_state'] = $contact_info['state'];
$partner[$array_key]['contact_zip'] = $contact_info['zip'];
$partner[$array_key]['contact_country'] = $contact_info['country'];
$partner[$array_key]['contact_notes'] = $contact_info['staff_notes'];
if ($passports[strtolower($contact_info['email'])]) {
$partner[$array_key]['contact_phpbb_user'] = $passports[strtolower($contact_info['email'])];
}
$partner[$array_key]['contact_phone_area'] = "";
$partner[$array_key]['contact_phone_prefix'] = "";
$partner[$array_key]['contact_phone_suffix'] = "";
$partner[$array_key]['contact_phone_ext'] = "";
if ($contact_info['phone_area'] && $contact_info['phone_prefix'] && $contact_info['phone_suffix']) {
$partner[$array_key]['contact_phone_area'] = $contact_info['phone_area'];
$partner[$array_key]['contact_phone_prefix'] = $contact_info['phone_prefix'];
$partner[$array_key]['contact_phone_suffix'] = $contact_info['phone_suffix'];
$partner[$array_key]['contact_phone_ext'] = $contact_info['phone_ext'];
$partner[$array_key]['contact_phone'] = "({$contact_info['phone_area']}) {$contact_info['phone_prefix']}-{$contact_info['phone_suffix']}";
if ($contact_info['phone_ext'] != "") { $partner[$array_key]['contact_phone'] .= " x" . $contact_info['phone_ext']; }
}
if ($contact_info['fax_area'] && $contact_info['fax_prefix'] && $contact_info['fax_suffix']) {
$partner[$array_key]['contact_fax_area'] = $contact_info['fax_area'];
$partner[$array_key]['contact_fax_prefix'] = $contact_info['fax_prefix'];
$partner[$array_key]['contact_fax_suffix'] = $contact_info['fax_suffix'];
$partner[$array_key]['contact_fax_ext'] = $contact_info['fax_ext'];
$partner[$array_key]['contact_fax'] = "({$contact_info['fax_area']}) {$contact_info['fax_prefix']}-{$contact_info['fax_suffix']}";
if ($contact_info['fax_ext'] != "") { $partner[$array_key]['contact_fax'] .= " x" . $contact_info['fax_ext']; }
}
$partner['extra_contacts'] .= " Name: " . $contact_info['name'];
$partner['extra_contacts'] .= "\nTitle: " . $contact_info['title'];
$partner['extra_contacts'] .= "\nPhone: " . $partner[$array_key]['contact_phone'];
$partner['extra_contacts'] .= "\nEmail: " . $contact_info['email'];
$partner['extra_contacts'] .= "\n[ ] Placement Contact\n\n";
}
}
if ($passports[strtolower($partner['admin_email'])]) {
$partner['admin_phpbb_user'] = $passports[strtolower($partner['admin_email'])];
}
if ($passports[strtolower($partner['director_email'])]) {
$partner['director_phpbb_user'] = $passports[strtolower($partner['director_email'])];
}
// Add in partner_project details...
if (is_numeric($projectid)) { $project_search = "AND (id = {$projectid})"; $partner['projectid'] = $projectid; }
$project_result = my_db_query("select * from `partner_project` where (partner_id = '{$partner_info['id']}') {$project_search} order by id asc", $db);
$partner['project_details'] = array();
while ($project_info = mysql_fetch_assoc($project_result)) {
$num_projects = array_push($partner['project_details'],$project_info);
$partner['projectids'][] = $project_info['id'];
// Get location info for this specific location...
if ($locationid) {
$lookuploc = " and (partner_locations.id = {$locationid})";
}
//$locations_result = my_db_query("SELECT * FROM partner_locations WHERE (partnerid = {$partnerid}) AND ((projectid = {$project_info['id']}) || (`location_type` like 'main')){$lookuploc}");
//echo "\n\n";
$locations_result = my_db_query("SELECT partner_locations.* FROM partner_locations_link LEFT JOIN partner_locations ON partner_locations.id = partner_locations_link.locationid WHERE (partner_locations_link.partnerid = {$partnerid}) AND ((partner_locations_link.projectid = {$project_info['id']}) OR (partner_locations_link.projectid = '')) AND (`partner_locations`.`status` like 'active'){$lookuploc}", $db);
while ($location = mysql_fetch_assoc($locations_result)) {
$project_key = $num_projects - 1;
if (($location['location_type'] == "main") || ($locationid == $location['id'])) {
$partner['main_locationid'] = $location['id'];
if ($location['lat'] && $location['lon']) {
$partner['lat'] = $location['lat'];
$partner['lon'] = $location['lon'];
}
$partner['address1'] = $location['address1'];
$partner['address2'] = $location['address2'];
$partner['city'] = $location['city'];
$partner['state'] = $location['state'];
$partner['region'] = $location['region'];
$partner['zip'] = $location['zip'];
$partner['country'] = $location['country'];
$partner['email'] = $location['email'];
$partner['partner_email'] = $location['email'];
if ($location['url']) $partner['url'] = $location['url'];
$partner['phone_area'] = $location['phone_area'];
$partner['phone_prefix'] = $location['phone_prefix'];
$partner['phone_suffix'] = $location['phone_suffix'];
$partner['phone_ext'] = $location['phone_ext'];
if ($location['phone_area'] && $location['phone_prefix'] && $location['phone_suffix']) {
$partner['partner_phone'] = "({$location['phone_area']}) {$location['phone_prefix']}-{$location['phone_suffix']}";
if ($location['phone_ext']) $partner['partner_phone'] .= " x {$location['phone_ext']}";
}
$partner['fax_area'] = $location['fax_area'];
$partner['fax_prefix'] = $location['fax_prefix'];
$partner['fax_suffix'] = $location['fax_suffix'];
if ($location['fax_area'] && $location['fax_prefix'] && $location['fax_suffix']) {
$partner['partner_fax'] = "({$location['fax_area']}) {$location['fax_prefix']}-{$location['fax_suffix']}";
if ($location['fax_ext']) $partner['partner_fax'] .= " x {$location['fax_ext']}";
} else {
unset($partner['partner_fax'], $partner['partner_fax_area'], $partner['partner_fax_prefix'], $partner['partner_fax_suffix'], $partner['partner_fax_ext']);
}
}
$partner['project_details'][$project_key]['locations'][$location['id']] = $location;
}
}
// Determine which projectid to use...
if ($partner['projectid']) {
$lookupid = $partner['projectid'];
} else {
$lookupid = $partner['projectids'][0];
}
// If locationid is specified, limit to that contact...
if ($locationid) {
$lookuploc = " and (locationid = {$locationid})";
}
// Get placement contact for this partner/project/location...
if (is_numeric($projectid) && $projectid) { $project_search = " AND (projectid = {$projectid})"; } else { $project_search = ""; }
//echo "my_db_query(\"select * from placement_contacts where (partnerid = {$partner_info['id']}){$project_search}{$lookuploc}\");\n";
$placement_result = my_db_query("select * from `placement_contacts` where (partnerid = {$partner_info['id']}){$project_search}{$lookuploc}", $db);
if (mysql_numrows($placement_result)) {
// Because this loops through all placement contacts for this partner/project/location, it may
// encounter more than one. In which case, it will store all but assign only the first it finds...
while ($placement = mysql_fetch_assoc($placement_result)) {
$placement_contact = $all_contacts[$placement['contactid']];
// Store found record...
$partner['project_details'][array_search($placement['projectid'],$partner['projectids'])]['placement_contacts'][$placement['locationid']] = $placement_contact;
$partner['project_details'][array_search($placement['projectid'],$partner['projectids'])]['placement_contacts'][$placement['locationid']]['phpbb_user'] = $placement['phpbb_user'];
//echo "Storing \n";
//print_r($placement);
//echo "
\n";
// Assign as placement contact...
if (!$partner['placement_name']) {
$partner['placement_name'] = $placement_contact['name'];
$partner['placement_email'] = $placement_contact['email'];
$partner['placement_title'] = $placement_contact['title'];
$partner['placement_phpbb_user'] = $placement['phpbb_user'];
if ($placement_contact['phone_area'] && $placement_contact['phone_prefix'] && $placement_contact['phone_suffix']) {
$partner['placement_phone'] = "({$placement_contact['phone_area']}) {$placement_contact['phone_prefix']}-{$placement_contact['phone_suffix']}";
if ($placement_contact['phone_ext']) {
$partner['placement_phone'] .= " x {$placement_contact['phone_ext']}";
}
}
$partner['placement_phone_area'] = $placement_contact['phone_area'];
$partner['placement_phone_prefix'] = $placement_contact['phone_prefix'];
$partner['placement_phone_suffix'] = $placement_contact['phone_suffix'];
$partner['placement_phone_ext'] = $placement_contact['phone_ext'];
}
}
// Partner application using the cristina_tmp db...
} else if (($db == "cristina_tmp") && ($partner['project_details'][0]['placement_contact'])) {
$placement_result = my_db_query("SELECT * FROM `partner_contacts` WHERE (`id` = {$partner['project_details'][0]['placement_contact']})", $db);
if (mysql_numrows($placement_result)) {
$placement_contact = mysql_fetch_assoc($placement_result);
if ($placement_contact['name'] && $placement_contact['email']) {
$partner['placement_name'] = $placement_contact['name'];
$partner['placement_email'] = $placement_contact['email'];
$partner['placement_phpbb_user'] = $placement['phpbb_user'];
if ($placement_contact['phone_area'] && $placement_contact['phone_prefix'] && $placement_contact['phone_suffix']) {
$partner['placement_phone'] = "({$placement_contact['phone_area']}) {$placement_contact['phone_prefix']}-{$placement_contact['phone_suffix']}";
if ($placement_contact['phone_ext']) {
$partner['placement_phone'] .= " x {$placement_contact['phone_ext']}";
}
}
$partner['placement_phone_area'] = $placement_contact['phone_area'];
$partner['placement_phone_prefix'] = $placement_contact['phone_prefix'];
$partner['placement_phone_suffix'] = $placement_contact['phone_suffix'];
$partner['placement_phone_ext'] = $placement_contact['phone_ext'];
}
}
// Not stored in the new way, try the old...
// This is necessary until we fully switch on the CN...
} else {
$partner['placement_contact'] = $partner_info['placement_contact'];
if ($partner['placement_contact'] == "email") {
$partner['placement_name'] = $partner['partner_name'];
$partner['placement_email'] = $partner['partner_email'];
$partner['placement_phone'] = $partner['partner_phone'];
$partner['placement_phone_area'] = $partner['partner_phone_area'];
$partner['placement_phone_prefix'] = $partner['partner_phone_prefix'];
$partner['placement_phone_suffix'] = $partner['partner_phone_suffix'];
$partner['placement_phone_ext'] = $partner['partner_phone_ext'];
} elseif ($partner['placement_contact'] == "admin_email") {
$partner['placement_name'] = $partner['admin_name'];
$partner['placement_email'] = $partner['admin_email'];
$partner['placement_phone'] = $partner['admin_phone'];
$partner['placement_phone_area'] = $partner['admin_phone_area'];
$partner['placement_phone_prefix'] = $partner['admin_phone_prefix'];
$partner['placement_phone_suffix'] = $partner['admin_phone_suffix'];
$partner['placement_phone_ext'] = $partner['admin_phone_ext'];
} elseif ($partner['placement_contact'] == "director_email") {
$partner['placement_name'] = $partner['director_name'];
$partner['placement_email'] = $partner['director_email'];
$partner['placement_phone'] = $partner['director_phone'];
$partner['placement_phone_area'] = $partner['director_phone_area'];
$partner['placement_phone_prefix'] = $partner['director_phone_prefix'];
$partner['placement_phone_suffix'] = $partner['director_phone_suffix'];
$partner['placement_phone_ext'] = $partner['director_phone_ext'];
} elseif ($partner['placement_contact'] && (preg_match("/@/", $partner['placement_contact']))) {
$contact_result = my_db_query("SELECT * FROM `partner_contacts` WHERE `email` = '" . mysql_escape_string($partner['placement_contact']) . "'", $db);
$contact_num = mysql_numrows($contact_result);
if ($contact_num > 0) {
$contact_info = mysql_fetch_array($contact_result);
$partner['placement_name'] = $contact_info['name'];
if ($contact_info['phone_area'] && $contact_info['phone_prefix'] && $contact_info['phone_suffix']) {
$partner['placement_phone_area'] = $contact_info['phone_area'];
$partner['placement_phone_prefix'] = $contact_info['phone_prefix'];
$partner['placement_phone_suffix'] = $contact_info['phone_suffix'];
$partner['placement_phone_ext'] = $contact_info['phone_ext'];
$partner['placement_phone'] = "({$contact_info['phone_area']}) {$contact_info['phone_prefix']}-{$contact_info['phone_suffix']}";
if ($contact_info['phone_ext'] != "") { $partner['placement_phone'] .= " x" . $contact_info['phone_ext']; }
}
}
$partner['placement_email'] = $partner['placement_contact'];
if ($partner['placement_phone'] == "") {
$partner['placement_phone'] = $partner['partner_phone'];
}
}
}
// Build contact address info...
$partner['partner_contact_text'] = " {$partner['org_name']}\n";
$partner['partner_contact_text'] .= " Attn: {$partner['placement_name']}\n";
$partner['partner_contact_text'] .= " {$partner['address1']}\n";
$partner['partner_contact_html'] = "{$partner['org_name']}
\n";
$partner['partner_contact_html'] .= "Attn: {$partner['placement_name']}
\n";
$partner['partner_contact_html'] .= "{$partner['address1']}
\n";
if ($partner['address2']) {
$partner['partner_contact_text'] .= " {$partner['address2']}\n";
$partner['partner_contact_html'] .= "{$partner['address2']}
\n";
}
$partner['partner_contact_text'] .= " {$partner['city']}, {$partner['state']} {$partner['zip']}\n";
$partner['partner_contact_html'] .= "{$partner['city']}, {$partner['state']} {$partner['zip']}
\n";
if ($partner['region']) {
$partner['partner_contact_text'] .= " {$partner['region']}\n";
$partner['partner_contact_html'] .= "{$partner['region']}
\n";
}
$partner['partner_contact_text'] .= " {$partner['country']}\n";
$partner['partner_contact_html'] .= "{$partner['country']}
\n";
$partner['partner_contact_text'] .= "\n Phone: {$partner['placement_phone']}\n";
$partner['partner_contact_html'] .= "
\n";
// Build email signature...
$partner['partner_signature_text'] .= "{$partner['placement_name']}\n";
$partner['partner_signature_text'] = "{$partner['org_name']}\n";
$partner['partner_signature_text'] .= "{$partner['address1']}\n";
$partner['partner_signature_html'] .= "{$partner['placement_name']} \n";
if ($partner['partner_fax']) {
$partner['partner_contact_text'] .= " Fax: {$partner['partner_fax']}\n";
$partner['partner_contact_html'] .= "Phone: {$partner['placement_phone']} Fax: {$partner['partner_fax']} \n";
}
if ($partner['placement_email']) {
$partner['partner_contact_text'] .= " Email: {$partner['placement_email']}\n";
$partner['partner_contact_html'] .= " \n";
}
$partner['partner_contact_html'] .= "Email: {$partner['placement_email']}
\n";
$partner['partner_signature_html'] = "{$partner['org_name']}
\n";
$partner['partner_signature_html'] .= "{$partner['address1']}
\n";
if ($partner['address2']) {
$partner['partner_signature_text'] .= "{$partner['address2']}\n";
$partner['partner_signature_html'] .= "{$partner['address2']}
\n";
}
$partner['partner_signature_text'] .= "{$partner['city']}, {$partner['state']} {$partner['zip']}\n";
$partner['partner_signature_html'] .= "{$partner['city']}, {$partner['state']} {$partner['zip']}
\n";
if ($partner['region']) {
$partner['partner_signature_text'] .= "{$partner['region']}\n";
$partner['partner_signature_html'] .= "{$partner['region']}
\n";
}
// $partner['partner_signature_text'] .= "{$partner['country']}\n";
// $partner['partner_signature_html'] .= "{$partner['country']}
\n";
$partner['partner_signature_text'] .= "\nPhone: {$partner['placement_phone']}\n";
$partner['partner_signature_html'] .= "
\n";
// Build general partner address info...
$partner['partner_address_text'] .= " {$partner['address1']}\n";
$partner['partner_address_html'] .= "{$partner['address1']} \n";
if ($partner['partner_fax']) {
$partner['partner_signature_text'] .= "Fax: {$partner['partner_fax']}\n";
$partner['partner_signature_html'] .= "Phone: {$partner['placement_phone']} Fax: {$partner['partner_fax']} \n";
}
if ($partner['placement_email']) {
$partner['partner_signature_text'] .= "Email: {$partner['placement_email']}\n";
$partner['partner_signature_html'] .= " \n";
}
$partner['partner_signature_html'] .= "Email: {$partner['placement_email']}
\n";
if ($partner['partner_address2']) {
$partner['partner_address_text'] .= " {$partner['address2']}\n";
$partner['partner_address_html'] .= "{$partner['address2']}
\n";
}
$partner['partner_address_text'] .= " {$partner['city']}, {$partner['state']} {$partner['zip']}\n";
$partner['partner_address_html'] .= "{$partner['city']}, {$partner['state']} {$partner['zip']}
\n";
if ($partner['region']) {
$partner['partner_address_text'] .= " {$partner['region']}\n";
$partner['partner_address_html'] .= "{$partner['region']}
\n";
}
$partner['partner_address_text'] .= " {$partner['country']}\n";
$partner['partner_address_html'] .= "{$partner['country']}
\n";
}
// What memberships does this org hold?
$memberships_result = my_db_query("SELECT `memberships`.`scopeid`, `memberships_scopes`.`name` AS `membership`, `memberships_scopes`.`desc`, `memberships`.`member_since` FROM `memberships_scopes`, `memberships` WHERE (`memberships`.`scopeid` = `memberships_scopes`.`id`) AND (`memberships`.`member_db` LIKE 'cristina') AND (`memberships`.`member_table` LIKE 'partner_info') AND (`memberships`.`member_id` = " . mysql_escape_string($partnerid) . ")");
if (mysql_numrows($memberships_result)) {
while ($membership = mysql_fetch_assoc($memberships_result)) {
$partner['memberships'][$membership['scopeid']] = $membership;
}
}
// Which staff member typically deals with this US partner?
$region_result = my_db_query("select user from regions where state = '{$partner['state']}'");
$region_num = mysql_numrows($region_result);
if ($region_num > 0) {
$user = mysql_fetch_assoc($region_result);
$staff_result = my_db_query("select `name`, `extension` from `dtap_settings` where user = '{$user['user']}'");
$staff_num = mysql_numrows($staff_result);
if ($staff_num > 0) {
$staff = mysql_fetch_assoc($staff_result);
$partner['staff_user'] = $user['user'];
$partner['staff_name'] = $staff['name'];
$partner['staff_ext'] = $staff['extension'];
}
// Must not be in the US...
} else {
// Default to Nancy for International partners...
$partner['staff_user'] = "nancy";
$partner['staff_name'] = "Nancy Cortez";
$partner['staff_ext'] = "364";
}
// echo "\n";
return $partner;
}
if (!function_exists('validate_email')) {
function validate_email($email_address) {
$email_addresses = split(",", $email_address);
$valid = false;
for ($i=0;$i\n";
//print_r($meta_info);
//echo "depth={$depth}\nparent_id={$parent_id}\nshow_desc={$show_desc}\nlist_type={$list_type}\nlimit={$limit}\n\n";
if (preg_match("/ul/i",$list_type) || preg_match("/ol/i",$list_type)) {
$li = "
\n
\n";
}
}
}
unset($writeonce);
return;
}
function send_file($file_name, $header_message = "") {
$base_name = basename($file_name);
$file_extension = strtolower(substr(strrchr($base_name,"."),1));
// Translate file name properly for Internet Explorer...
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")){
$download_name = preg_replace('/\./', '%2e', $base_name, substr_count($base_name, '.') - 1);
} else {
$download_name = $base_name;
}
//This will set the Content-Type to the appropriate setting for the file
switch ($file_extension) {
case "htm":
case "xhtml";
case "txt";
case "html": $content_type="text/html"; break;
case "pdf": $content_type="application/pdf"; break;
case "doc": $content_type="application/msword"; break;
case "exe": $content_type="application/octet-stream"; break;
case "zip": $content_type="application/zip"; break;
case "xls": $content_type="application/vnd.ms-excel"; break;
case "ppt": $content_type="application/vnd.ms-powerpoint"; break;
case "gif": $content_type="image/gif"; break;
case "png": $content_type="image/png"; break;
case "jpeg":
case "jpg": $content_type="image/jpeg"; break;
case "mp3": $content_type="audio/mpeg"; break;
case "wav": $content_type="audio/x-wav"; break;
case "mpeg":
case "mpg":
case "mpe": $content_type="video/mpeg"; break;
case "mov": $content_type="video/quicktime"; break;
case "avi": $content_type="video/x-msvideo"; break;
default: $content_type="application/force-download";
}
if ($header_message != "") header("Custom-message: {$header_message}");
// Make sure the file exists before sending headers...
if (!$fdl = @fopen($file_name,'r')) {
error_out("Cannot Open File!");
} else {
// Leave blank to avoid IE errors...
header("Cache-Control: ");
// Leave blank to avoid IE errors...
header("Pragma: ");
if ($content_type) {
header("Content-type: {$content_type}");
} else {
header("Content-type: application/octet-stream");
}
// header("Content-Disposition: attachment; filename=\"" . $download_name . "\"");
header("Content-length:" . (string)(filesize($file_name)));
//
// feof/echo fread is faster and easier on RAM
//
// fpassthru($fdl);
//
while(!feof($fdl)) {
$buffer = fread($fdl, 2048);
echo $buffer;
}
fclose($fdl);
}
return;
}
function clear_lock($key, $user = "", $force = false) {
// Make sure we're using the correct content tables...
if ($GLOBALS['content_table']) {
$content_table = $GLOBALS['content_table'];
} else {
$content_table = "website_content";
}
if ($key != "") {
$result = my_db_query("SELECT locked,lock_id,lock_user,lock_epoch FROM {$content_table} WHERE `key` = '$key'", "cristina_tmp");
if (mysql_num_rows($result) > 0) {
$lock_data = mysql_fetch_assoc($result);
if ($lock_data['lock_user'] == $user || $force) {
//remove lock
$result = my_db_query("UPDATE {$content_table} SET locked = 0, lock_id = '', lock_user = '', lock_epoch = 0 WHERE `key` = '$key'", "cristina_tmp");
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
//
// $format = list|partial|full|rss
//
function list_news($how_many = 5, $section = "all", $format = "list", $category = "", $subcategory = "", $tags = "") {
$sections_available = array("article", "blog", "feedback", "url");
if ($section == "all" && ($format != "rss" && $format != "atom")) {
echo "\n";
echo "\n \n";
}
for ($i=0;$i<$chunknum;$i++) {
$spacing = str_pad("", $depth*4, " ");
unset($option_spacing);
switch ($depth) {
case 1:
//if (preg_match("/ul/i",$list_type)) { $list_class = " class=\"ovalBullet\""; }
$option_spacing = "";
$option_style = " style=\"background-color:#FFEAB9;\"";
break;
case 2:
//if (preg_match("/ul/i",$list_type)) { $list_class = " class=\"normalBullet\""; }
$option_spacing = " » ";
$option_style = " style=\"background-color:#FEF5DA;\"";
break;
case 3:
//if (preg_match("/ul/i",$list_type)) { $list_class = " class=\"normalBullet\""; }
$option_spacing = " » ";
$option_style = " style=\"background-color:#FFFAD9\"";
break;
case 4:
//if (preg_match("/ul/i",$list_type)) { $list_class = " class=\"normalBullet\""; }
$option_spacing = " » ";
$option_style = " style=\"background-color:#FFFFEC;\"";
break;
case 5:
//if (preg_match("/ul/i",$list_type)) { $list_class = " class=\"normalBullet\""; }
$option_spacing = " » ";
$option_style = " style=\"background-color:#FFFFFF;\"";
break;
}
if (preg_match("/option/i",$list_type)) {
$option_array = explode(":",$list_type);
$value_type = $option_array[2];
if (!$value_type || ($value_type == "id")) {
$selected_id = $option_array[1];
} else if ($value_type == "key") {
$selected_key = $option_array[1];
}
}
// Main section entry...
if ($parent_id == 0) {
$this_class = "subHead";
// Start a new main-list...
if (!$writeonce) {
if (!preg_match("/option/i",$list_type) && !preg_match("/guidenav/i",$list_type)) {
echo "<{$list_type}{$list_class}>\n";
$writeonce = true;
}
}
// Subnav entry...
} else {
$this_class = "subnavLink";
// Start a new sub-list...
if ($display['parent_id'][$i] != $last_parent_id) {
if (!preg_match("/option/i",$list_type) && !preg_match("/guidenav/i",$list_type)) {
echo "{$spacing}Table of Contents \n \n \n";
// Inactive main level section...
} else if ($depth == 1) {
echo " {$display['title'][$i]} \n \n \n";
// Active sub section...
} else if ($meta_info['id'] == $display['id'][$i]) {
echo " {$display['title'][$i]} \n \n \n";
// Inactive sub section...
} else {
echo " {$display['title'][$i]} \n \n \n";
}
}
if ($show_desc && (!preg_match("/guidenav/i",$list_type))) {
echo "{$display['title'][$i]} \n
|
|
Link to this page: http://www.cristina.org/article/" . $permalink_tail . "
Posted: " . $resource['date_created'] . " by " . trim($resource['author']) . "\n";
} elseif ($format == "full") {
echo "
";
if (!preg_match("/http:\/\/www.cristina.org\//i", $resource['url'])) echo "Read The Full Article (" . preg_replace("/^www./", "", $url_split[2]) . ")";
else echo " ";
echo "\n";
} elseif (trim($resource['url']) != "") {
echo "\n\nRead the full article:\n{$resource['url']}\n\n";
}
echo "
Link to this page: {$resource['title']}";
echo "
Originally Published: {$resource['date_published']} by {$resource['author']} at {$resource['publisher']}\n";
} elseif ($format == "rss") {
// Cleanup text for feed display...
$description = preg_replace("/\"\/dbimages\//","\"http://www.cristina.org/dbimages/",stripslashes($resource['article_text']));
$description = preg_replace("/\"\/images\//","\"http://www.cristina.org/images/",stripslashes($description));
$description = preg_replace("//","",$description);
$description .= "
|
|
\n";
echo "\n";
echo "Link to this page: http://www.cristina.org/feedback/" . $permalink_tail . "
\n";
echo "Written: " . date("M j, Y", strtotime($resource['date_provided'])) . " by " . trim($resource['author']) . "
\n";
echo "Posted: " . date("M j, Y", strtotime($resource['date_created'])) . " by " . ucwords(trim($resource['creator'])) . "\n";
echo "\n";
*/
} elseif ($format == "full") {
//echo "
\n";
echo "\n";
echo "Link to this page: http://www.cristina.org/feedback/" . $permalink_tail . "
\n";
echo "Written: " . date("M j, Y", strtotime($resource['date_provided'])) . " by " . trim($resource['author']) . "
\n";
echo "Posted: " . date("M j, Y", strtotime($resource['date_created'])) . " by " . ucwords(trim($resource['creator'])) . "\n";
echo "\n";
*/
} elseif ($format == "rss") {
$description = stripslashes($resource['feedback_text']);
$description .= "Written: " . date("M j, Y", strtotime($resource['date_provided'])) . " by " . trim($resource['author']) . "\n";
if ($category != "") {
$description .= " ($category";
if ($subcategory != "") {
$description .= ":$subcategory";
}
$description .=")\n";
}
$description = preg_replace("/‘|’|“|”/", "'", $description);
$description = str_replace("—", "-", $description);
$description = str_replace(" ", " ", $description);
$description = str_replace(" & ", " and ", $description);
echo "
|
|
Read The Full Blog (" . preg_replace("/^www./", "", $url_split[2]) . ")\n";
} elseif (trim($resource['url']) != "") {
echo "\n\nRead the full Blog:\n{$resource['url']}\n\n";
}
echo "
Link to this page: {$resource['title']}";
echo "
Originally Published: {$resource['date_published']} by " . stripslashes($resource['author']) . " at {$resource['publisher']}\n";
} elseif ($format == "rss") {
$description = preg_replace("/\"\/images\/","\"http:\/\/www.cristina.org\/images\/",stripslashes($resource['blog_text']));
$description = preg_replace("//","",$description);
$description .= "
Please include a complete title and comment when posting a new comment.
";
} elseif ($userdata['session_logged_in']) {
if ($userdata['is_admin']) {
$status = "public";
my_db_query("INSERT INTO resource_comment (`key`, status, title, creator, comment_text, date_created, reviewer, date_reviewed)
VALUES ('$key', '$status', '" . mysql_escape_string($comment_title) . "', '" . $userdata['username'] . "', '" . mysql_escape_string($comment_text) . "', NOW(), '" . $userdata['username'] . "', NOW())");
} else {
$status = "pending";
my_db_query("INSERT INTO resource_comment (`key`, status, title, creator, comment_text, date_created)
VALUES ('$key', '$status', '" . mysql_escape_string($comment_title) . "', '" . $userdata['username'] . "', '" . mysql_escape_string($comment_text) . "', NOW())");
}
echo "
Your comment has been entered!
";
} else {
echo "
We're sorry, you must be logged in to submit a new comment.
";
}
}
echo "
/* OLD METHOD...
echo " \n";
echo "
echo str_replace("\n","
",htmlentities(stripslashes($comment['comment_text']))); ?>
echo date("g:i A F nS, Y", strtotime($comment['date_created'])); ?>
\n", htmlentities(stripslashes($comment['comment_text']))) . "
\n";
}
echo "
\n";
if ($userdata['session_logged_in']) {
comment_form($key);
} else {
$prompt = "Want to leave a comment? Please log in!";
passport_form($prompt);
}
}
function comment_form($this_key) {
global $_SERVER;
if ($_SERVER["HTTPS"] == "on") {
$method = "https://";
} else {
$method="http://";
}
if ($_SERVER['QUERY_STRING'] != '') $_SERVER['QUERY_STRING'] = '?' . $_SERVER['QUERY_STRING'];
$this_page = $method . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING'];
?>
}}
function passport_form($prompt = "Cristina Passport Login") {
global $_SERVER, $userdata;
if ($_SERVER["HTTPS"] == "on") {
$method = "https://";
} else {
$method="http://";
}
if (preg_match("/passport_register/", $_SERVER["PHP_SELF"])) {
$this_page = $method . $_SERVER["HTTP_HOST"] . "/welcome.html";
} else {
if ($_SERVER["QUERY_STRING"] != "") $_SERVER["QUERY_STRING"] = "?" . $_SERVER["QUERY_STRING"];
$this_page = $method . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRING"];
}
if ($userdata['session_logged_in']) {
// do nothing
// echo "\n
}
}
//
// Generate feed category list and form...
//
function feed_category_list() {
// Get all categories and subcategories from database...
$category_result = my_db_query("SELECT id,type,category,description FROM resource_categories WHERE xml_feed = 1 ORDER BY type, category");
$category_num = mysql_numrows($category_result);
$subcategory_result = my_db_query("SELECT id,categoryid,subcategory,description FROM resource_subcategories WHERE xml_feed = 1 ORDER BY subcategory");
$subcategory_num = mysql_numrows($subcategory_result);
// Generate array of all feed types/categories/subcategories...
while ($cat = mysql_fetch_assoc($category_result)) {
if ($prev != $cat['type']) {
$list_array[] = $cat['type'];
$prev = $cat['type'];
$categories = $cat['type'];
}
$descid = "{$cat['type']}_{$cat['id']}";
$descriptions[$descid] = $cat['description'];
${$categories}[] = $cat['category'];
$list_array[$cat['type']][$cat['id']] = $cat['category'];
mysql_data_seek($subcategory_result, 0);
while ($subcat = mysql_fetch_assoc($subcategory_result)) {
if ($cat['id'] == $subcat['categoryid']) {
$subcategories = $cat['type'] . "_" . $cat['category'];
$descid = "{$cat['type']}_{$cat['id']}_{$subcat['id']}";
$descriptions[$descid] = $subcat['description'];
${$subcategories}[] = $subcat['subcategory'];
$list_array[$cat['type']][$cat['category']][$subcat['id']] = $subcat['subcategory'];
}
}
}
//echo "\n";
$type_keys = array_keys($list_array);
foreach ($type_keys as $key) {
if (!is_int($key)) {
$types[] = $key;
//echo "\n";
foreach ($$key as $this_cat) {
$this_subcat = $key . "_" . $this_cat;
if (is_array($$this_subcat)) {
//echo "\n";
}
}
}
}
//echo "\n";
?>
}
function page_is_live($key, $quiet = true) {
// Make sure we're using the correct content/archive tables...
if ($GLOBALS['content_table'] && $GLOBALS['archive_table']) {
$content_table = $GLOBALS['content_table'];
$archive_table = $GLOBALS['archive_table'];
} else {
$content_table = "website_content";
$archive_table = "website_archive";
}
$result_live = my_db_query("SELECT * FROM {$content_table} WHERE `key` = '" . $key . "'");
if (mysql_num_rows($result_live) == 0) {
if (!$quiet) echo "This page does not exist on the live site. Publish Live";
return false;
} else {
$live_info = mysql_fetch_assoc($result_live);
$result_proto = my_db_query("SELECT * FROM {$content_table} WHERE `key` = '" . $key . "'", "cristina_tmp");
$proto_info = mysql_fetch_assoc($result_proto);
if ($live_info['content'] != $proto_info['content']) {
if (!$quiet) echo "This page's content differs from the live site. Publish Live";
return false;
} elseif ($live_info['title'] != $proto_info['title']) {
if (!$quiet) echo "This page's title differs from the live site. Publish Live";
return false;
} elseif (($live_info['priority'] != $proto_info['priority']) || ($live_info['keywords'] != $proto_info['keywords']) || ($live_info['subnav'] != $proto_info['subnav']) || ($live_info['subnav_title'] != $proto_info['subnav_title']) || ($live_info['sitemap'] != $proto_info['sitemap']) || ($live_info['width'] != $proto_info['width']) || ($live_info['bottom_nav'] != $proto_info['bottom_nav'])) {
if (!$quiet) echo "This page's settings differ from the live site. Publish Live";
return false;
}
}
return true;
}
function log_this_page($scope = "") {
global $_SERVER, $_GET, $_POST, $session_login, $donorid, $sessionid, $partnerid, $resource;
//
// gather info
//
$browser = mysql_escape_string($_SERVER["HTTP_USER_AGENT"]);
$request_uri = mysql_escape_string($_SERVER["REQUEST_URI"]);
$remote_ip = $_SERVER["REMOTE_ADDR"];
$local_ip = $_SERVER["SERVER_ADDR"];
$server_name = $_SERVER["SERVER_NAME"];
$method = $_SERVER["REQUEST_METHOD"];
// Make sure all INT fields are entered properly...
$int_fields = array("donorid","partnerid","resource_id");
foreach($int_fields as $field) {
if ($$field && (!is_numeric($$field))) {
$set_field = "this_" . $field;
$$set_field = 404;
} else {
$set_field = "this_" . $field;
$$set_field = $$field;
}
}
if ($this_donorid == "") { $this_donorid = 0; }
if ($this_partnerid == "") { $this_partnerid = 0; }
if ($GLOBALS['log_this_page_resource_id'] == "") { $GLOBALS['log_this_page_resource_id'] = 0; }
$GLOBALS['log_this_page_resource_type'] = preg_replace("/^resource_/", "", $GLOBALS['log_this_page_resource_type']);
$get_vars = mysql_escape_string(print_r($_GET, TRUE));
$post_vars = mysql_escape_string(print_r($_POST, TRUE));
$table_name = date("Y-M") . "_access_logs";
my_db_query("INSERT INTO `$table_name` (`scope`, `remote_ip`, `server_ip`, `server_name`, `request_uri`, `donorid`, `sessionid`, `partnerid`, `resource_type`, `resource_id`, `browser`, `session_login`, `method`, `get_vars`, `post_vars`) VALUES
('$scope', '$remote_ip', '$local_ip', '$server_name', '$request_uri', $this_donorid, '$sessionid', $this_partnerid, '{$GLOBALS['log_this_page_resource_type']}', {$GLOBALS['log_this_page_resource_id']}, '$browser', '$session_login', '$method', '$get_vars', '$post_vars')", "cristina_logging");
}
function var_training($post_only_vars,$post_or_get_vars) {
//
// training... this should help us recognize new post values
//
$post_vars = array_keys($_POST);
for ($i = 0;$i < sizeof($post_vars);$i++) {
if (!is_array($post_only_vars) || !in_array($post_vars[$i], $post_only_vars)) {
$post_only_vars[] = $post_vars[$i];
}
my_db_query("INSERT INTO website_variables (varname, method, initial_request_uri) VALUES ('{$post_vars[$i]}', 'POST', '" . mysql_escape_string($_SERVER['REQUEST_URI']) . "') ON DUPLICATE KEY UPDATE last_request_uri='" . mysql_escape_string($_SERVER['REQUEST_URI']) . "'");
}
//
// training... this should help us recognize new get values
//
$get_vars = array_keys($_GET);
for ($i = 0;$i < sizeof($get_vars);$i++) {
if (!is_array($post_or_get_vars) || !in_array($get_vars[$i], $post_or_get_vars)) {
$post_or_get_vars[] = $get_vars[$i];
}
my_db_query("INSERT INTO website_variables (varname, method, initial_request_uri) VALUES ('{$get_vars[$i]}', 'GET', '" . mysql_escape_string($_SERVER['REQUEST_URI']) . "') ON DUPLICATE KEY UPDATE last_request_uri='" . mysql_escape_string($_SERVER['REQUEST_URI']) . "'");
}
}
function get_generations($table, $showgens = array('1','2','3','4'), $offset = 0, $scope = "dsf", $hidden = 0, $consolidated = true, $return = "display") {
//
// $hidden [0/1] allows you to choose between hidden and non-hidden objects
// $consolidated [0/1] allows you to alter the display to consolidate the options when displaying them
//
// Quick little function to add the offset...
if (!function_exists('add_offset')) {
function add_offset(&$val,$key,$offset) {
$val = $val + $offset;
}
}
// $showgens isn't in array format...
if (!is_array($showgens)) {
// Range Format: 1-3
if (preg_match("/-/",$showgens)) {
$gens = explode("-",trim($showgens));
$firstgen = $gens[0];
$lastgen = $gens[1];
if (is_numeric($firstgen) && is_numeric($lastgen) && ($firstgen <= $lastgen)) {
for ($i = $firstgen;$i <= $lastgen;$i++) {
$generations[] = $i;
}
} else {
echo "Error: generations ({$showgens}) not in proper format (for exmaple: 1-4)\n";
exit;
}
// Delimited Format: 1,3,4
} else if (preg_match("/,/",$showgens)) {
$generations = explode(",",$showgens);
// Singular Format: 3
} else if (is_numeric($showgens)) {
$generations = array($showgens);
} else if ($showgens == "all") {
// Get max generation possible...
$max_result = my_db_query("select MAX(generation) as max_gen from form_options");
$max_gen = mysql_result($max_result,0,"max_gen");
for ($i = 0;$i <= $max_gen;$i++) {
$generations[] = $i;
}
} else if ($showgens == "active") {
//
// Get all active generations
//
unset($where_fields);
$form_result = my_db_query("SELECT field_name, field_title_text FROM form_fields WHERE (table_name='$table' AND is_generational=1) ORDER BY display_order asc");
while ($fields = mysql_fetch_assoc($form_result)) {
if ($where_fields != "") $where_fields .= " OR ";
$where_fields .= "field_name='" . $fields['field_name'] . "'";
}
if ($where_fields != "") {
$max_result = my_db_query("select MAX(generation) as max_gen, MIN(generation) as min_gen from form_options WHERE (($where_fields) AND table_name='$table' AND generation != 0 AND hidden=0)");
$max_gen = mysql_result($max_result,0,"max_gen");
$min_gen = mysql_result($max_result,0,"min_gen");
for ($i = $min_gen;$i <= $max_gen;$i++) {
$generations[] = $i;
}
} else {
// echo "
Warning: This item type has no generational options associated with it.
";
}
} else {
echo "Error: generations ({$showgens}) in unknown format, please use one of the following: [1-4], [1,3,4], [3], [array(\"1\",\"3\",\"4\")]\n";
exit;
}
} else {
$generations = $showgens;
}
$master_array['gen_min'] = 1000; // something really high, it comes DOWN from here.
$master_array['gen_max'] = 0; // something really low, it goes UP from here.
//
// Get list of item fields for generational display...
//
$is_numeric = false;
if (is_array($generations)) {
// Add any specified offset...
array_walk($generations,"add_offset",$offset);
//
// loop through each gen selected
//
foreach ($generations as $gen) {
unset($prev_option,$is_numeric);
//
// handle the min/max settings
//
if ($gen < $master_array['gen_min']) $master_array['gen_min'] = $gen;
if ($gen > $master_array['gen_max']) $master_array['gen_max'] = $gen;
$display_gen = $gen - $offset;
$display_array[$display_gen] = array();
$form_result = my_db_query("SELECT field_name, field_title_text, is_generational FROM form_fields WHERE (table_name='$table' AND (is_generational=1 or is_generational=2)) ORDER BY display_order asc");
while ($fields = mysql_fetch_assoc($form_result)) {
$master_array['is_generational'][$fields['field_name']] = $fields['is_generational'];
$master_array['is_generational'][$fields['field_title_text']] = $fields['is_generational'];
$master_array['text2table'][$fields['field_title_text']] = $fields['field_name'];
$master_array['table2text'][$fields['field_name']] = $fields['field_title_text'];
unset($prev_option,$is_numeric);
if ($consolidated) {
// Grouped option, get em all...
if ($fields['is_generational'] == 2) {
$generational_result = my_db_query("SELECT DISTINCT option_text FROM form_options WHERE (table_name='$table' AND field_name='{$fields['field_name']}' AND hidden=$hidden) ORDER BY field_name, sort_order");
$debug .= "Searching for grouped field {$fields['field_name']} options (consolidated)...\n";
// Strctly a generational field, get this gen and higher...
} else {
$generational_result = my_db_query("SELECT DISTINCT option_text FROM form_options WHERE (table_name='$table' AND field_name='{$fields['field_name']}' AND generation>=$gen AND hidden=$hidden) ORDER BY field_name, sort_order");
$debug .= "Searching for field {$fields['field_name']} options (consolidated)...\n";
}
} else {
$generational_result = my_db_query("SELECT DISTINCT option_text FROM form_options WHERE (table_name='$table' AND field_name='{$fields['field_name']}' AND generation=$gen AND hidden=$hidden) ORDER BY field_name, sort_order");
$debug .= "Searching for field {$fields['field_name']} options (generation specific)...\n";
}
while ($options = mysql_fetch_assoc($generational_result)) {
// Add to master array...
if (is_array($master_array[$display_gen][$fields['field_title_text']])) {
array_push($master_array[$display_gen][$fields['field_title_text']],$options['option_text']);
} else {
$master_array[$display_gen][$fields['field_title_text']] = array_values($options);
}
//
// try to detect numbers showing up all in a row
//
if (preg_match("/^([0-9]{1,20})/", $options['option_text'])) {
if (!$is_numeric) {
$is_numeric = true;
if ($display_array[$display_gen][$fields['field_title_text']]) { $display_array[$display_gen][$fields['field_title_text']] .= ", "; $action = "Adding to"; } else { $action = "Setting"; }
$display_array[$display_gen][$fields['field_title_text']] .= $options['option_text'];
$debug .= "{$action} {$fields['field_title_text']} = {$options['option_text']}\n";
} else {
$prev_option = $options['option_text'];
$debug .= "Storing previous as {$options['option_text']}\n";
}
} else {
if (!$is_numeric) {
unset($prev_option);
if ($display_array[$display_gen][$fields['field_title_text']]) { $display_array[$display_gen][$fields['field_title_text']] .= ", "; }
$display_array[$display_gen][$fields['field_title_text']] .= $options['option_text'];
$debug .= "Adding to {$fields['field_title_text']} = {$options['option_text']}\n";
} else {
$is_numeric = false;
if ($prev_option) {
if ($consolidated) {
$display_array[$display_gen][$fields['field_title_text']] .= " - {$prev_option}";
}
$action = "Finishing range of {$fields['field_title_text']} with {$prev_option} and adding {$options['option_text']}";
} else {
$action = "Adding to {$fields['field_title_text']} = {$options['option_text']}";
}
if ($display_array[$display_gen][$fields['field_title_text']]) { $display_array[$display_gen][$fields['field_title_text']] .= ", "; }
$display_array[$display_gen][$fields['field_title_text']] .= $options['option_text'];
$debug .= "{$action}\n";
}
}
}
if ($is_numeric && $prev_option) {
$is_numeric = false;
if ($consolidated) {
$display_array[$display_gen][$fields['field_title_text']] .= " - {$prev_option}";
}
$debug .= "Finishing range of {$fields['field_title_text']} with {$prev_option}\n";
}
}
}
} else {
$master_array['gen_min'] = 0;
$master_array['gen_max'] = 0;
}
/*
echo "\n";
echo "\n[Display Array]\n";
print_r($display_array);
echo "\n[Master Array]\n";
print_r($master_array);
echo "
\n";
echo "\n";
echo "\n[Debug Info]\n";
echo $debug;
echo "
\n";
*/
if ($return == "display") {
return $display_array;
} else if ($reutrn = "master") {
return $master_array;
}
}
function donor_passport_link($donorid = 0, $email = "") {
global $userdata;
if ($userdata['user_id'] != 0 && $userdata['user_id'] != -1) {
if ($donorid != 0 && $email != "") {
$result = my_db_query("SELECT donorid FROM donor_info WHERE (donorid = $donorid AND email LIKE '$email')");
if (mysql_num_rows($result) > 0) {
my_db_query("DELETE FROM donor_passport_link WHERE (phpbb_user_id = {$userdata['user_id']} AND donorid = {$donorid})");
my_db_query("INSERT INTO donor_passport_link (phpbb_user_id, donorid) VALUES ({$userdata['user_id']}, {$donorid})");
//echo "\n";
}
}
$result = my_db_query("SELECT donorid FROM donor_info WHERE (email LIKE '" . $userdata['user_email'] . "')");
while ($donor_info = mysql_fetch_assoc($result)) {
my_db_query("DELETE FROM donor_passport_link WHERE (phpbb_user_id = {$userdata['user_id']} AND donorid = {$donor_info['donorid']})");
my_db_query("INSERT INTO donor_passport_link (phpbb_user_id, donorid) VALUES ({$userdata['user_id']}, {$donor_info['donorid']})");
//echo "\n";
}
}
}
function partner_passport_link($partnerid = 0, $email = "") {
global $userdata;
$group_add = false;
//echo "\n";
if ($userdata['user_id'] != 0 && $userdata['user_id'] != -1) {
if ($partnerid != 0 && trim($email) != "") {
$result = my_db_query("SELECT id FROM partner_info WHERE ($id = $partnerid AND (email LIKE '$email' OR admin_email LIKE '$email' OR director_email LIKE '$email')) and (status like 'active')");
if (mysql_num_rows($result) > 0) {
// my_db_query("DELETE FROM partner_passport_link WHERE (phpbb_user_id = {$userdata['user_id']} AND partnerid = {$partnerid})");
my_db_query("INSERT IGNORE INTO partner_passport_link (phpbb_user_id, partnerid) VALUES ({$userdata['user_id']}, {$partnerid})");
if (!$group_add) {
my_db_query("USE phpbb3");
group_user_add(9, array($userdata['user_id']));
$group_add = true;
my_db_query("USE cristina");
}
//echo "\n";
}
}
if (trim($userdata['user_email']) != "") {
unset($partner_info);
$result = my_db_query("SELECT partnerid FROM partner_contacts WHERE (email LIKE '" . $userdata['user_email'] . "')");
while ($partner_info = mysql_fetch_assoc($result)) {
// my_db_query("DELETE FROM partner_passport_link WHERE (phpbb_user_id = {$userdata['user_id']} AND partnerid = {$partner_info['partnerid']})");
my_db_query("INSERT IGNORE INTO partner_passport_link (phpbb_user_id, partnerid) VALUES ({$userdata['user_id']}, {$partner_info['partnerid']})");
if (!$group_add) {
my_db_query("USE phpbb3");
group_user_add(9, array($userdata['user_id']));
$group_add = true;
my_db_query("USE cristina");
}
//echo "\n";
}
}
}
}
function donation_history($partnerid, $sessionid, $donorid, $format = "table_summary", $db = "cristina") {
$donor_result = my_db_query("SELECT * FROM donor_info WHERE donorid = $donorid", $db);
if (mysql_num_rows($donor_result) > 0) {
$donor_info = mysql_fetch_assoc($donor_result);
} else {
error_out("No such donor Donor ID: $donorid");
}
//
// not sure we need this?
// ... but wrote it anyway...
//
// $partner_result = my_db_query("SELECT * FROM partner_info WHERE id = $partnerid");
// if (mysql_num_rows($partner_result) > 0) {
// $partner_info = mysql_fetch_assoc($partner_result);
// } else {
// error_out("No such partner Partner ID: $partnerid");
// }
if ($partnerid != "") {
$partner_where = " AND (partnerid = '$partnerid' OR partnerid REGEXP '^$partnerid:' OR partnerid REGEXP ':$partnerid:')";
}
$session_result = my_db_query("SELECT * FROM donation_summary WHERE (donorid = $donorid AND sessionid = '$sessionid' $partner_where)", $db);
if (mysql_num_rows($session_result) < 1) {
if ($db = "cristina_tmp") {
// echo "
No equipment was entered: Donor ID: '$donorid' / Session ID: '$sessionid'
\n";
} else {
echo "
No such session Partner ID: '$partnerid' / Donor ID: '$donorid' / Session ID: '$sessionid'
\n";
}
return;
} else {
$items_num = mysql_num_rows($session_result);
}
//
// snag the proper referrer logo
//
$ref_array = get_link_ref($donor_info['link_ref']);
$source_logo = $ref_array['source_logo'];
$source_alt = $ref_array['source_alt'];
//
// donor name
//
if (trim($donor_info['company']) == "") {
$donor_name = $donor_info['name'];
} else {
$donor_name = $donor_info['company'];
}
$receipt_query_done = false;
$header_done = false;
while ($session_info = mysql_fetch_assoc($session_result)) {
//
// date to display
//
if ($db == "cristina_tmp") {
$date_header = "Entered";
$date_text = date("m\/d\/y", strtotime($session_info['date']));
} elseif ($session_info['placement_date'] != "") {
$date_header = "Placement";
$date_text = date("m\/d\/y", strtotime($session_info['placement_date']));
} elseif ($session_info['match_date'] != "") {
$date_header = "Matched";
$date_text = date("m\/d\/y", strtotime($session_info['match_date']));
} else {
$date_header = "Pledged";
$date_text = date("m\/d\/y", strtotime($session_info['date']));
}
if ($db == "cristina_tmp") {
$session_sum_result = my_db_query("SELECT * FROM session_summary WHERE donorid = $donorid AND sessionid = '$sessionid'", $db);
$session_array = mysql_fetch_assoc($session_sum_result);
$pledge_date = date("F jS, Y, g:i a", strtotime($session_array['timestamp']));
} else {
$pledge_date = date("F jS, Y, g:i a", strtotime($session_info['date']));
}
if (!$header_done) {
?>
if ($resume_url != "") {
// $resume_url = " Resume This Donation \n";
echo "
$header_done = true;
}
// if ($session_info['status'] != "complete") {
// $item_desc = strtoupper($session_info['status']);
// } else {
$item_result = my_db_query("SELECT * FROM `{$session_info['table_name']}` WHERE id = {$session_info['itemid']}", $db);
if (mysql_num_rows($item_result) > 0) {
$item_info = mysql_fetch_array($item_result);
$item_desc = "";
$field_array = array("manufacturer", "manu_other", "model", "processor_type");
for ($i = 0; $i < sizeof($field_array); $i++) {
$field_name = $field_array[$i];
if ($field_name == "model") {
if ($item_desc != "") $item_desc .= ", ";
$item_desc .= $item_info[$field_name];
} elseif ($item_info[$field_name] != "" && $field_name != "model") {
if ($item_desc != "") $item_desc .= ", ";
$item_result_b = my_db_query("SELECT option_text FROM form_options WHERE (option_value = '" . mysql_escape_string($item_info[$field_name]) . "' AND table_name = '{$session_info['table_name']}' AND field_name = '$field_name' AND display_when = '{$item_info['knowledge_path']}')");
$add_item_info = mysql_fetch_assoc($item_result_b);
$item_desc .= $add_item_info['option_text'];
}
}
}
// }
if ($format == "table_summary") {
$receipt_value = "0";
$receipt_num = "";
if ($session_info['status'] == "complete" && !$receipt_query_done) {
$receipt_result = my_db_query("SELECT * FROM receipt_values WHERE (donorid = $donorid AND sessionid = '$sessionid' AND partnerid = '$partnerid')", $db);
$receipt_query_done = true;
}
@mysql_data_seek($receipt_result, 0);
while ($receipt_info = @mysql_fetch_assoc($receipt_result)) {
if ($receipt_info['table_name'] == $session_info['table_name'] && $receipt_info['itemid'] == $session_info['itemid']) {
$receipt_value = $receipt_info['item_value'];
$receipt_num = $receipt_info['receipt_id'];
}
}
}
$table_name = strtoupper(str_replace("_", " ", $session_info['table_name']));
?>
if ($format == "table_summary") {
?>
} ?>
unset($item_desc);
$receipt_total = $receipt_total + $receipt_value;
$quantity_total = $quantity_total + $session_info['quantity'];
}
?>
if ($format == "table_summary") {
?>
} ?>
if ($format == "table_summary") {
?>
}
if ($db == "cristina_tmp") {
$session_summary_result = my_db_query("SELECT * FROM session_summary WHERE donorid='$donorid' AND sessionid='$sessionid'", $db);
$session_info = mysql_fetch_assoc($session_summary_result);
echo " \n";
echo " \n";
} else { ?>
} ?>
\n";
}
}
function get_link_ref($link_ref) {
//
// returns an array with:
//
// source_logo set to an image path
// source_alt set to appropriate alt text
//
if ($link_ref == "MVI") {
$source_logo = "images/list_logo/mvi_list_logo.png";
$source_alt = "Market Velocity referred donor...";
} else if ($link_ref == "Dell") {
$source_logo = "images/list_logo/dell_list_logo.png";
$source_alt = "Dell referred donor...";
} else if ($link_ref == "MVI HP") {
$source_logo = "images/list_logo/hp_list_logo.png";
$source_alt = "HP referred donor...";
} else if ($link_ref == "MVI Ingram") {
$source_logo = "images/list_logo/ingram_list_logo.png";
$source_alt = "Ingram Micro referred donor...";
} else if ($link_ref == "Wacom") {
$source_logo = "images/list_logo/wacom_list_logo.gif";
$source_alt = "Wacom referred donor...";
} else if ($link_ref == "PC Magazine") {
$source_logo = "images/list_logo/pcmag_list_logo.gif";
$source_alt = "PC Magazine referred donor...";
} else if ($link_ref == "Dell Canada") {
$source_logo = "images/list_logo/dell_canada_list_logo.png";
$source_alt = "Dell Canada referred donor...";
} else if ($link_ref == "Dell Canada Corporate") {
$source_logo = "images/list_logo/dell_canada_list_logo.png";
$source_alt = "Dell Canada Corporate referred donor...";
} else if ($link_ref == "TigerDirect") {
$source_logo = "images/list_logo/tigerdirect_list_logo.png";
$source_alt = "TigerDirect referred donor...";
} else if ($link_ref == "eBay Rethink") {
$source_logo = "images/list_logo/ebay_list_logo.png";
$source_alt = "eBay referred donor...";
} else if ($link_ref == "Epson") {
$source_logo = "images/list_logo/epson_list_logo.png";
$source_alt = "Epson referred donor...";
} else if ($link_ref == "Xerox") {
$source_logo = "images/list_logo/xerox_list_logo.png";
$source_alt = "Xerox referred donor...";
} else if ($link_ref == "ASCII Group") {
$source_logo = "images/list_logo/ascii_list_logo.png";
$source_alt = "ASCII Group referred donor...";
} else if ($link_ref == "CompTIA") {
$source_logo = "images/list_logo/comptia_list_logo.png";
$source_alt = "CompTIA referred donor...";
} else if ($link_ref == "Veteran Program") {
$source_logo = "images/list_logo/veteran_list_logo.png";
$source_alt = "Veteran Program referred donor...";
} else if ($link_ref == "Anheuser") {
$source_logo = "images/list_logo/anheuser_list_logo.png";
$source_alt = "Anheuser-Busch referred donor...";
} else if ($link_ref == "Newspaper") {
$source_logo = "images/list_logo/newspaper_list_logo.png";
$source_alt = "Newspaper referred donor...";
} else if ($link_ref == "Word of Mouth") {
$source_logo = "images/list_logo/mouth_list_logo.png";
$source_alt = "Word of Mouth referred donor...";
} else if ($link_ref == "Internet Search") {
$source_logo = "images/list_logo/google_list_logo.png";
$source_alt = "Internet Search referred donor...";
} else if ($link_ref == "Corporate%") {
if (preg_match("/Morgan Stanley/i",$company)) {
$source_logo = "images/list_logo/morgan_stanley_list_logo.png";
$source_alt = "Morgan Stanley referred donor...";
} else if (preg_match("/Honeywell/i",$company)) {
$source_logo = "images/list_logo/honeywell_list_logo.png";
$source_alt = "Honeywell referred donor...";
}
} else if (preg_match("/craters/i",$link_ref)) {
$source_logo = "images/list_logo/craters_list_logo.png";
$source_alt = "{$link_ref} referred donor...";
} else if ($link_ref == "dTap" || $link_ref == "") {
$source_logo = "images/list_logo/dtap_list_logo.png";
$source_alt = "dTap entry by staff...";
} else {
$source_logo = "images/list_logo/default_list_logo.png";
$source_alt = "{$link_ref} referred donor...";
}
if (preg_match("/Morgan Stanley/i",$company)) {
$source_logo = "images/list_logo/morgan_stanley_list_logo.png";
$source_alt = "Morgan Stanley referred donor...";
} else if (preg_match("/Honeywell/i",$company)) {
$source_logo = "images/list_logo/honeywell_list_logo.png";
$source_alt = "Honeywell referred donor...";
}
if (!$source_logo) {
$source_logo = "images/list_logo/default_list_logo.png";
$source_alt = "{$link_ref} referred donor...";
}
$this_array['source_logo'] = $source_logo;
$this_array['source_alt'] = $source_alt;
return $this_array;
}
if (!function_exists('dollarformat')) {
function dollarformat($input) {
$weight = sprintf("%01.2f", $input);
if ($input >= 0) {
if (strlen($weight) == 12) $weight = substr($weight, -12, 3) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 11) $weight = substr($weight, -11, 2) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 10) $weight = substr($weight, -10, 1) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 9) $weight = substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 8) $weight = substr($weight, -8, 2) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 7) $weight = substr($weight, -7, 1) . "," . substr($weight, -6, 6);
} else {
if (strlen($weight) == 13) $weight = substr($weight, -13, 4) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 12) $weight = substr($weight, -12, 3) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 11) $weight = substr($weight, -11, 2) . "," . substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 10) $weight = substr($weight, -10, 4) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 9) $weight = substr($weight, -9, 3) . "," . substr($weight, -6, 6);
elseif (strlen($weight) == 8) $weight = substr($weight, -8, 2) . "," . substr($weight, -6, 6);
}
return $weight;
}}
if (!function_exists('cache_page')) {
function cache_page($seconds = 10800) { // default = 3 hrs
header('Expires: ' . gmdate('D, d M Y H:i:s',time()+$seconds) . ' GMT');
header("Cache-Control: max-age=$seconds");
header('Pragma:');
}}
if (!function_exists('array_stripslashes')) {
function array_stripslashes($value) {
if (!is_array($value)) {
return stripslashes($value);
} else {
return array_map("array_stripslashes",$value);
}
}}
if (!function_exists('getNth')) {
function getNth($n) {
$qn = (int) (($n%100) / 10);
$rn = $n % 10;
$suffix = "th";
if ($qn != 1) {
switch ($rn) {
case 1: $suffix = "st"; break;
case 2: $suffix = "nd"; break;
case 3: $suffix = "rd"; break;
}
}
return $n . $suffix;
}}
if (!function_exists('check_do_not_email')) {
function check_do_not_email($address) {
$address_on_blacklist = false;
$res_to_check = preg_match_all("/[a-z0-9]+([+#\'_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", strtolower(trim($address)), $matches_to_check);
if (sizeof($GLOBALS['do_not_email_list'] < 1)) {
$result = my_db_query("SELECT email FROM do_not_email");
if (mysql_numrows($result)) {
while($do_not_email = mysql_fetch_assoc($result)) {
$res = preg_match_all("/[a-z0-9]+([+#\'_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", strtolower(trim($do_not_email['email'])), $matches);
if ($res) {
foreach(array_unique($matches[0]) as $email) {
$GLOBALS['do_not_email_list'][] = strtolower(trim($email));
}
}
}
}
}
if ($res_to_check && sizeof($GLOBALS['do_not_email_list']) > 0) {
foreach(array_unique($matches_to_check[0]) as $email) {
if (in_array($email, $GLOBALS['do_not_email_list'])) {
$address_on_blacklist = true;
}
}
}
return $address_on_blacklist;
}}
if (!function_exists('count_tag_usage')) {
function count_tag_usage() {
$result_tags = my_db_query("SELECT DISTINCT concat(tag_id, '-', resource_table) as taginfo, tag_id, resource_table, count(id) AS count_id FROM `resource_tags_map` WHERE 1 GROUP BY taginfo ORDER BY count_id DESC");
while ($tag_info = mysql_fetch_assoc($result_tags)) {
unset($count_column);
if ($tag_info['resource_table'] == "resource_article") {
$count_column = "article_count";
} elseif ($tag_info['resource_table'] == "resource_comment") {
$count_column = "comment_count";
} elseif ($tag_info['resource_table'] == "resource_url") {
$count_column = "url_count";
} elseif ($tag_info['resource_table'] == "resource_file") {
$count_column = "file_count";
} elseif ($tag_info['resource_table'] == "resource_contact") {
$count_column = "contact_count";
} elseif ($tag_info['resource_table'] == "resource_feedback") {
$count_column = "feedback_count";
} elseif ($tag_info['resource_table'] == "resource_blog") {
$count_column = "blog_count";
} elseif ($tag_info['resource_table'] == "resource_tags") {
$count_column = "tag_count";
} elseif ($tag_info['resource_table'] == "partner_info") {
$count_column = "partner_count";
} elseif ($tag_info['resource_table'] == "donor_info") {
$count_column = "donor_count";
}
if ($count_column != "") {
my_db_query("UPDATE resource_tags SET {$count_column} = {$tag_info['count_id']} WHERE id = {$tag_info['tag_id']}");
}
}
}}
if (!function_exists('filter_xss')) {
function filter_xss($val) {
if (is_array($val)) {
foreach ($val as $key => $value) {
$val[$key] = filter_xss($value);
}
} else {
// remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed
// this prevents some character re-spacing such as